/* FuelSnap — ruhig, viel Weißraum, große Zahlen, ein Akzent (Grün). Zuerst fürs Handy. */

:root {
  --text: #111412;
  --text-2: #6b716d;
  --text-3: #9aa09c;
  --bg: #ffffff;
  --surface: #f4f5f4;
  --surface-2: #e9ebe9;
  --border: #e3e6e4;
  --accent: #1e9e55;
  --accent-text: #ffffff;
  --accent-soft: #e6f4ec;
  --warning: #b26a00;
  --danger: #c2362f;
  --fat: #6b716d;
  --carbs: #9aa09c;
  --radius: 16px;
  --radius-sm: 12px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #f1f3f2;
    --text-2: #9aa29d;
    --text-3: #6a716c;
    --bg: #0b0d0c;
    --surface: #151917;
    --surface-2: #1e2320;
    --border: #252b28;
    --accent: #3ccb78;
    --accent-text: #06120b;
    --accent-soft: #13291c;
    --warning: #f0a43a;
    --danger: #f0645c;
    --fat: #9aa29d;
    --carbs: #6a716c;
    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.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.app { min-height: 100dvh; }
.screen {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 112px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
body.no-tabs .screen { padding-bottom: calc(env(safe-area-inset-bottom) + 112px); }

/* Typografie */
h1, .title { font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; margin: 0; }
h2, .heading { font-size: 20px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.display { font-size: 56px; line-height: 1; font-weight: 700; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.number { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.small { font-size: 13px; line-height: 1.4; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.warn { color: var(--warning); }
.error { color: var(--danger); font-size: 14px; }
.notice { color: var(--accent); }
.kicker { font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.center { text-align: center; }
p { margin: 0; }

/* Bausteine */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.top { align-items: flex-start; }
.row.base { align-items: baseline; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 > *, .grid3 > * { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.back { display: inline-flex; align-items: center; gap: 2px; color: var(--text-2); font-size: 15px; margin-left: -6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 24px; border-radius: var(--radius);
  border: 0; cursor: pointer; font-weight: 600; font-size: 16px;
  background: var(--accent); color: var(--accent-text);
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--text); }
.btn.ghost { background: none; color: var(--accent); min-height: 44px; }
.btn.block { width: 100%; }
.btn.busy { opacity: .7; pointer-events: none; }

/* Fixe Aktionsleiste (Onboarding, Einstellungen) */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 20px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.actionbar .inner { max-width: 520px; margin: 0 auto; display: flex; gap: 10px; }
.actionbar .btn { flex: 1; }
.actionbar .btn.main { flex: 2; }

/* Felder */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span:first-child { font-size: 13px; color: var(--text-2); }
.input {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: var(--radius-sm);
  border: 1.5px solid transparent; padding: 0 16px;
}
.card .input { background: var(--bg); }   /* sonst verschwindet das Feld auf der Karte */
.input:focus-within { border-color: var(--accent); }
.input.invalid { border-color: var(--danger); }
.input input, .input select {
  flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: none;
  padding: 14px 0; font-size: 16px;   /* 16px verhindert Zoom auf dem iPhone */
}
.input .suffix { color: var(--text-2); }

/* Segmentschalter auf Basis von Radio-Buttons */
.seg { display: flex; gap: 3px; padding: 3px; background: var(--surface); border-radius: 14px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1; min-height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 11px; font-size: 14px; font-weight: 600; color: var(--text-2); cursor: pointer;
  white-space: nowrap; transition: background .15s, color .15s;
}
.seg input:checked + label { background: var(--bg); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (prefers-color-scheme: dark) { .seg input:checked + label { background: var(--surface-2); box-shadow: none; } }

/* Chips und Auswahlkarten */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .choice {
  border: 1.5px solid transparent; background: var(--surface); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chip { border-radius: 999px; padding: 9px 15px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.chip.on, .chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip input, .choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice { display: flex; flex-direction: column; gap: 2px; border-radius: var(--radius); padding: 16px; }
.choice b { font-weight: 600; }
.choice:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.choice:has(input:focus-visible), .chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Schritt-Fortschritt */
.steps { display: flex; gap: 4px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); }
.steps i.on { background: var(--accent); }
.step { display: none; flex-direction: column; gap: 16px; }
.step.on { display: flex; }

/* Kalorienring */
.ring { position: relative; width: 236px; height: 236px; margin: 0 auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 14; stroke-linecap: round; transition: stroke-dasharray .45s ease; }
.ring .ring-track { stroke: var(--surface-2); }
.ring .ring-range { stroke: var(--accent-soft); }
.ring .ring-fill { stroke: var(--accent); }
.ring .ring-fill.over { stroke: var(--warning); }
.ring .zero { opacity: 0; }  /* sonst zeigt die runde Kappe einen Punkt bei 0 */
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* Makros */
.macro { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; transition: width .45s ease; }
.bar i.protein { background: var(--accent); }
.bar i.fat { background: var(--fat); }
.bar i.carbs { background: var(--carbs); }

/* Kamera-Knopf */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 15;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);
  height: 64px; padding: 0 28px; border-radius: 999px; border: 0;
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--accent); color: var(--accent-text); font-weight: 650; font-size: 17px;
  box-shadow: 0 8px 24px rgba(30, 158, 85, .28);
}
.fab:disabled { opacity: .45; box-shadow: none; }

/* Tab-Leiste */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; max-width: 140px; height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 11px; font-weight: 600;
}
.tabbar a.active { color: var(--accent); }

/* Listen */
.list { display: flex; flex-direction: column; gap: 8px; }
.list a.item { color: var(--text); }
.list .item { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }

.code { font-size: 22px; font-weight: 650; letter-spacing: .12em; font-variant-numeric: tabular-nums; user-select: all; }

@media (min-width: 720px) {
  .screen { padding-top: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Kamera */
label.btn input[type=file] { display: none; }
.thumbs { display: flex; gap: 8px; justify-content: center; }
.thumbs img { width: 120px; height: 120px; object-fit: cover; border-radius: var(--radius-sm); }
.loader { width: 56px; height: 56px; margin: 8px auto; border-radius: 50%; border: 5px solid var(--surface-2); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.line { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.line.hidden-line { margin-left: 18px; background: none; border: 1.5px dashed var(--border); }
.line.uncertain { box-shadow: inset 3px 0 0 var(--warning); }
.line .kcal { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.line details summary { cursor: pointer; color: var(--accent); margin-top: 4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--warning); color: var(--bg); vertical-align: 2px; }
.badge.soft { background: var(--surface-2); color: var(--text-2); }
.clarify { margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg); display: flex; flex-direction: column; gap: 8px; }

.badge.ok { background: var(--accent); color: var(--accent-text); }
.grams-edit { all: unset; cursor: pointer; font-size: 13px; display: inline-flex; gap: 4px; align-items: baseline; padding: 2px 0; }
.grams-edit .edit-hint { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.grams-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.grams-form { display: flex; gap: 6px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.grams-form .input { flex: 1; min-width: 90px; background: var(--bg); }
.grams-form .btn { min-height: 44px; padding: 0 14px; }
