:root {
  --bg: #121418; --surface: #1a1d23; --surface2: #21252c; --surface3: #2a2f37; --border: #2e333c;
  --text: #e9ebee; --text2: #a4abb6; --text3: #6e7581; --accent: #1fc7b6; --accent-soft: #163c3a;
  --accent-text: #04201e; --danger: #ef6262; --danger-soft: #3d2224; --warn: #f2b84b; --water: #4aa8ff;
  --water-soft: #16304a; --p: #1fc7b6; --f: #f2b84b; --c: #8f7bff;
  --radius: 16px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f4f7; --surface: #ffffff; --surface2: #f4f6f8; --surface3: #e7eaef; --border: #dde1e7;
    --text: #171a1f; --text2: #4a5260; --text3: #8a919d; --accent: #0f9e90; --accent-soft: #d7f3ef;
    --accent-text: #ffffff; --danger: #d64545; --danger-soft: #fbe3e3; --warn: #c98a10; --water: #1f7fe0;
    --water-soft: #dcecfd; --p: #0f9e90; --f: #c98a10; --c: #6a55e0;
    color-scheme: light;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; overscroll-behavior-y: contain;
}
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; font-weight: 800; letter-spacing: 3px; color: var(--accent); }
[hidden] { display: none !important; }

/* ---------- Kopf, Inhalt, Navigation */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(10px + var(--safe-t)) 16px 8px; display: flex; align-items: center; gap: 10px;
  max-width: 640px; margin: 0 auto;
}
.onb ~ #toast, body:has(.onb) #toast { bottom: auto; top: calc(14px + var(--safe-t)); }
.top h1 { font-size: 20px; margin: 0; flex: 1; font-weight: 750; }
.top .sub { color: var(--text2); font-size: 13px; font-weight: 500; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--surface2); color: var(--text2);
  border: 1px solid var(--border); white-space: nowrap; }
.pill.ok { color: var(--accent); }
.pill.warn { color: var(--warn); }
.pill.err { color: var(--danger); }
main { padding: 4px 16px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + var(--safe-b));
}
nav.tabs button { background: none; border: 0; padding: 6px 0; color: var(--text3); font-size: 11px; display: flex;
  flex-direction: column; align-items: center; gap: 3px; }
nav.tabs button.on { color: var(--accent); }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs .fab { align-self: center; justify-self: center; width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); margin-top: -26px; box-shadow: 0 6px 18px rgba(0,0,0,.35);
  display: grid; place-items: center; padding: 0; }
nav.tabs .fab svg { width: 30px; height: 30px; }

/* ---------- Karten */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  margin: 10px 0; }
.card h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.card h2 .grow { flex: 1; }
.card h2 svg { width: 19px; height: 19px; color: var(--accent); flex: none; }
.water h2 svg { color: var(--water); }
.link svg { width: 18px; height: 18px; vertical-align: -4px; }
svg { flex: none; }
.muted { color: var(--text2); }
.faint { color: var(--text3); font-size: 13px; }
.small { font-size: 13px; }
.danger { color: var(--danger); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .8px; color: var(--text3); text-transform: uppercase;
  margin: 14px 2px 6px; }

.summary { display: flex; gap: 16px; align-items: center; }
.ring { position: relative; width: 116px; height: 116px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .lbl b { font-size: 22px; font-weight: 800; }
.ring .lbl span { font-size: 11px; color: var(--text2); }
.macros { flex: 1; display: grid; gap: 9px; }
.macro .head { display: flex; justify-content: space-between; font-size: 13px; color: var(--text2); }
.macro .head b { color: var(--text); font-weight: 650; }
.bar { height: 8px; border-radius: 99px; background: var(--surface3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s; }

.water .bar { height: 14px; }
.water .bar i { background: var(--water); }
.water .big { font-size: 22px; font-weight: 800; }
.btn-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }

/* ---------- Knöpfe & Eingaben */
.btn { border: 1px solid var(--border); background: var(--surface3); border-radius: 12px; padding: 12px 14px;
  font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
  cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.water { background: var(--water-soft); color: var(--water); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; }
.btn svg { width: 20px; height: 20px; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 8px 0; cursor: pointer; }
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 13px; color: var(--text2); margin-bottom: 5px; }
input.inp, select.inp, textarea.inp { width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; min-height: 46px; outline: none; }
input.inp:focus, textarea.inp:focus, select.inp:focus { border-color: var(--accent); }
textarea.inp { min-height: 96px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid4 label.field { margin: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chip { border: 1px solid var(--border); background: var(--surface2); color: var(--text2); padding: 8px 13px;
  border-radius: 99px; white-space: nowrap; font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { text-align: center; }
.stepper .btn { min-width: 46px; padding: 0; }
.switch { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.switch input { width: 46px; height: 28px; appearance: none; background: var(--surface3); border-radius: 99px;
  position: relative; flex: none; border: 1px solid var(--border); transition: .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--text2); transition: .2s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { left: 21px; background: var(--accent-text); }

/* ---------- Einträge */
.entry { display: flex; gap: 10px; align-items: center; padding: 11px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; margin: 6px 0; }
.entry .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface2);
  color: var(--text2); flex: none; }
.entry .ic svg { width: 17px; height: 17px; }
.entry .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .meta { font-size: 12.5px; color: var(--text2); }
.entry .kcal { font-weight: 750; white-space: nowrap; }
.entry.pending { border-style: dashed; }
.job { display: flex; gap: 12px; align-items: center; }
.job img, .job .ph { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex: none;
  background: var(--surface3); display: grid; place-items: center; color: var(--text2); }
.job .ph svg { width: 24px; height: 24px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--surface3); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.card.attention { border-color: var(--accent); background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.empty { text-align: center; color: var(--text2); padding: 22px 10px; }
.empty svg { width: 40px; height: 40px; color: var(--text3); }

/* ---------- Unterseiten (Sheet) */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--bg); border-radius: 20px 20px 0 0;
  max-height: 94vh; overflow-y: auto; padding: 8px 16px calc(18px + var(--safe-b)); max-width: 640px; margin: 0 auto;
  animation: up .2s ease-out; border-top: 1px solid var(--border); }
#sheet.full { top: 0; max-height: none; border-radius: 0; padding-top: calc(8px + var(--safe-t)); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-head { display: flex; align-items: center; gap: 8px; position: sticky; top: -8px; background: var(--bg);
  padding: 10px 0 8px; z-index: 2; }
.sheet-head h3 { margin: 0; font-size: 18px; flex: 1; }
.icon-btn { background: var(--surface2); border: 1px solid var(--border); width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; padding: 0; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.add-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 14px;
  text-align: left; display: flex; flex-direction: column; gap: 6px; min-height: 108px; }
.add-tile svg { width: 28px; height: 28px; color: var(--accent); }
.add-tile b { font-size: 16px; }
.add-tile span { font-size: 12.5px; color: var(--text2); }
.add-tile.wide { grid-column: span 2; min-height: auto; flex-direction: row; align-items: center; }

.scanner { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; left: 10%; right: 10%; top: 36%; height: 22%; border: 3px solid var(--accent);
  border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scanner .hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #fff; font-size: 14px;
  text-shadow: 0 1px 3px #000; }

.review-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; margin: 8px 0; }
.review-item .top-row { display: flex; gap: 8px; align-items: center; }
.review-item input.name { flex: 1; background: transparent; border: 0; font-weight: 650; padding: 4px 0; min-width: 0; outline: none; }
.review-item .vals { font-size: 12.5px; color: var(--text2); margin-top: 4px; }
.conf { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--surface3); color: var(--text2); }
.conf.low { color: var(--warn); }
.total-bar { position: sticky; bottom: calc(-18px - var(--safe-b)); background: var(--bg); padding: 10px 0 4px;
  border-top: 1px solid var(--border); margin-top: 10px; }

/* ---------- Einrichtung */
.onb { min-height: 100vh; display: flex; flex-direction: column; padding: calc(24px + var(--safe-t)) 22px calc(22px + var(--safe-b));
  max-width: 560px; margin: 0 auto; }
.onb .dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.onb .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--surface3); }
.onb .dots i.on { background: var(--accent); width: 20px; border-radius: 99px; }
.onb .hero { width: 84px; height: 84px; border-radius: 22px; margin: 10px auto 16px; display: block; }
.onb h2 { font-size: 25px; margin: 6px 0 10px; text-align: center; line-height: 1.2; }
.onb p { color: var(--text2); text-align: center; margin: 6px 0; }
.onb .body { flex: 1; }
.onb .actions { display: grid; gap: 8px; margin-top: 18px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 16px 0; }
.steps li { counter-increment: s; position: relative; padding: 12px 12px 12px 50px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; margin: 8px 0; color: var(--text); }
.steps li::before { content: counter(s); position: absolute; left: 12px; top: 10px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center;
  font-weight: 800; font-size: 14px; }
.steps li small { display: block; color: var(--text2); margin-top: 3px; }
.code-input { font-size: 30px; letter-spacing: 10px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.feature { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; }
.feature svg { width: 26px; height: 26px; color: var(--accent); flex: none; margin-top: 2px; }
.feature b { display: block; }
.feature span { color: var(--text2); font-size: 14px; }
.info { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; color: var(--text2);
  font-size: 14px; margin: 10px 0; }
.info.warn { border-color: var(--warn); color: var(--text); }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(92px + var(--safe-b)); z-index: 40; display: grid;
  justify-items: center; pointer-events: none; }
#toast div { background: var(--surface3); color: var(--text); border: 1px solid var(--border); padding: 11px 16px;
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.35); max-width: 520px; pointer-events: auto;
  animation: up .2s ease-out; display: flex; gap: 12px; align-items: center; }
#toast div.error { border-color: var(--danger); }
#toast div button { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 0; }
.days .day { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; margin: 8px 0; width: 100%; text-align: left; }
.days .day .d { width: 46px; text-align: center; flex: none; }
.days .day .d b { display: block; font-size: 20px; }
.days .day .d span { font-size: 12px; color: var(--text2); }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--surface3); color: var(--text2); }
.tag.ok { background: var(--accent-soft); color: var(--accent); }
