/* ===== Design-Tokens ===== */
:root {
  color-scheme: light;
  --bg: #f2f8f2;
  --surface: #ffffff;
  --surface-2: #edf6ed;
  --surface-3: #dcebdc;
  --ink: #132015;
  --ink-2: #4a5a4c;
  --muted: #6c7a6e;
  --line: #dcebdc;
  --grid: #e4efe4;
  --axis: #b9cfba;

  --accent: #2e7d32;          /* Buttons (weiße Schrift, 5,1:1) */
  --accent-ink: #2b7a36;      /* grüner Text auf Fläche */
  --accent-mark: #3f9b4b;     /* Ring, Balken, Linien */
  --accent-soft: #e2f2e3;
  --on-accent: #ffffff;

  /* grüner Kopfbereich mit weißer Schrift */
  --hero-bg: linear-gradient(160deg, #2e8540 0%, #237233 55%, #1f6b2b 100%);
  --hero-ink: #ffffff;
  --hero-ink-2: rgba(255, 255, 255, 0.88);
  --hero-glass: rgba(255, 255, 255, 0.16);
  --hero-line: rgba(255, 255, 255, 0.28);

  /* Makros: validierte kategoriale Reihenfolge (Eiweiß, Kohlenhydrate, Fett) */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;

  /* Status (immer mit Icon + Text) */
  --good: #0ca30c;
  --good-ink: #006300;
  --serious: #ec835a;
  --serious-ink: #b3471c;
  --critical: #d03b3b;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(31, 107, 43, 0.05), 0 6px 20px rgba(31, 107, 43, 0.07);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --tabbar-h: 66px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #252523;
    --surface-3: #31312e;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #93918a;
    --line: #2c2c2a;
    --grid: #2c2c2a;
    --axis: #45453f;
    --accent: #2e7d32;
    --accent-ink: #6cc070;
    --accent-mark: #4caf50;
    --accent-soft: #1f3321;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --good-ink: #3ec43e;
    --serious-ink: #f0956f;
    --shadow: none;
    --hero-bg: linear-gradient(160deg, #1f5527 0%, #183f1d 100%);
    --hero-ink: #ffffff;
    --hero-ink-2: rgba(255, 255, 255, 0.85);
    --hero-glass: rgba(255, 255, 255, 0.12);
    --hero-line: rgba(255, 255, 255, 0.22);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #252523;
  --surface-3: #31312e;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #93918a;
  --line: #2c2c2a;
  --grid: #2c2c2a;
  --axis: #45453f;
  --accent: #2e7d32;
  --accent-ink: #6cc070;
  --accent-mark: #4caf50;
  --accent-soft: #1f3321;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --good-ink: #3ec43e;
  --serious-ink: #f0956f;
  --shadow: none;
  --hero-bg: linear-gradient(160deg, #1f5527 0%, #183f1d 100%);
  --hero-ink: #ffffff;
  --hero-ink-2: rgba(255, 255, 255, 0.85);
  --hero-glass: rgba(255, 255, 255, 0.12);
  --hero-line: rgba(255, 255, 255, 0.22);
}

/* ===== Grundlagen ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.sheet-open { overflow: hidden; }
/* Grüner Streifen hinter der Statusleiste (iOS-App-Modus, weiße Statusleisten-Schrift) */
body::before {
  content: ''; position: fixed; z-index: 25; top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top); background: #237233;
}
a { color: var(--accent-ink); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1, .h1 { font-size: 1.6rem; font-weight: 700; }
p { margin: 0.4em 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.icon { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--accent-mark); outline-offset: 2px; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 32px;
  min-height: 100vh;
  overflow-x: clip;
}
body.has-tabbar #app { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 40px); }
#app[aria-busy='true'] > .view { opacity: 0.6; transition: opacity 0.2s 0.15s; }
.view { display: flex; flex-direction: column; gap: 12px; }

.offline-banner { display: none; }
body.is-offline .offline-banner {
  display: block; position: sticky; top: 0; z-index: 30;
  background: var(--ink); color: var(--bg); text-align: center; font-size: 0.85rem;
  padding: calc(env(safe-area-inset-top) + 4px) 12px 4px;
}

/* ===== Grüner Kopfbereich ===== */
.hero {
  margin: calc(-1 * (env(safe-area-inset-top) + 12px)) -16px 4px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 22px;
  background: var(--hero-bg);
  color: var(--hero-ink);
  border-radius: 0 0 30px 30px;
  display: flex; flex-direction: column; gap: 14px;
  position: relative; overflow: hidden; isolation: isolate;
}
.hero::before, .hero::after {
  content: ''; position: absolute; z-index: -1; border-radius: 50%; pointer-events: none;
  background: rgba(255, 255, 255, 0.07);
}
.hero::before { width: 260px; height: 260px; right: -90px; top: -110px; }
.hero::after { width: 180px; height: 180px; left: -70px; bottom: -120px; }
.hero h1, .hero .h1 { color: var(--hero-ink); }
.hero .muted, .hero .date-title small { color: var(--hero-ink-2); }
.hero a:not(.btn):not(.chip):not(.icon-btn) { color: var(--hero-ink); }
.hero .icon-btn, .hero .date-nav .icon-btn { background: var(--hero-glass); border: 0; color: var(--hero-ink); }
.hero .icon-btn:active { background: var(--hero-line); }
.btn-hero { background: #ffffff; color: #1f6b2b; }
.chip-hero { background: var(--hero-glass); border-color: var(--hero-line); color: var(--hero-ink); }
.hero-jump { margin: -6px 0 0; }
.hero .segmented { background: var(--hero-glass); border-color: transparent; }
.hero .segmented > a, .hero .segmented > button, .hero .segmented > label { color: var(--hero-ink-2); }
.hero .segmented > .active, .hero .segmented > label:has(input:checked) { background: #ffffff; color: #1f6b2b; }
.hero .search-field { background: #ffffff; border-color: transparent; color: #6c7a6e; }
.hero .search-field input { color: #132015; }
.hero .note, .hero .note .icon { color: var(--hero-ink); }
.hero .stat-label, .hero .progress-legend { color: var(--hero-ink-2); }
.hero .stat-value, .hero .progress-legend b { color: var(--hero-ink); }
.hero .stat-value small { color: var(--hero-ink-2); }
.hero .status-tag.good { color: var(--hero-ink); background: var(--hero-glass); border-radius: 99px; padding: 2px 8px 2px 6px; align-self: flex-start; }
.hero .progress { background: var(--hero-glass); }
.hero .progress i { background: #ffffff; }
.hero .avatar { background: #ffffff; color: #1f6b2b; }
body.has-tabbar .view > .hero:first-child, .view > .hero:first-child { margin-bottom: 4px; }
@media (min-width: 600px) {
  .hero { border-radius: 0 0 32px 32px; }
}

/* ===== Kopfzeilen ===== */
.page-head { display: flex; align-items: center; gap: 12px; padding: 6px 0 4px; }
.page-head.simple { justify-content: space-between; flex-wrap: wrap; }
.page-head.simple h1 { flex: 1; min-width: 0; }
.date-nav { justify-content: space-between; }
.date-title {
  position: relative; display: flex; flex-direction: column; align-items: center;
  cursor: pointer; padding: 2px 12px; border-radius: 14px;
}
.date-title small { color: var(--muted); font-size: 0.9rem; }
.date-title input {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
  border: 0; padding: 0; -webkit-appearance: none; appearance: none;
}
.date-title input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.profile-head { justify-content: flex-start; flex-wrap: nowrap; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 1.4rem;
}

/* ===== Karten ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 1.05rem; font-weight: 650; margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head .card-title { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.eyebrow { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; }
.hero-number { font-size: 2.2rem; font-weight: 700; margin: 2px 0 6px; letter-spacing: -0.02em; }
.hero-number small { font-size: 0.95rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }

/* ===== Tagesbilanz ===== */
.summary { display: grid; grid-template-columns: 148px 1fr; gap: 18px; align-items: center; }
.hero .summary { padding: 4px 4px 2px; }
.ring-wrap { position: relative; width: 148px; height: 148px; }
.ring { width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 11; }
.ring-track { stroke: var(--accent-soft); }
.ring-fill { stroke: var(--accent-mark); stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.ring.over .ring-track { stroke: color-mix(in srgb, var(--serious) 25%, var(--surface)); }
.ring.over .ring-fill { stroke: var(--serious); }
.hero .ring-track { stroke: var(--hero-glass); }
.hero .ring-fill { stroke: #ffffff; }
.hero .ring.over .ring-track { stroke: rgba(255, 196, 160, 0.3); }
.hero .ring.over .ring-fill { stroke: #ffc4a0; }
.hero .ring-label span { color: var(--hero-ink-2); }
.hero .ledger div { color: var(--hero-ink-2); }
.hero .ledger dd, .hero .ledger .total dt, .hero .ledger .total dd { color: var(--hero-ink); }
.hero .ledger .total { border-top-color: var(--hero-line); }
.hero .ledger .total.neg dd { color: #ffd2b8; }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label b { font-size: 1.85rem; letter-spacing: -0.02em; line-height: 1; }
.ring-label span { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.ledger { margin: 0; display: grid; gap: 6px; font-variant-numeric: tabular-nums; }
.ledger div { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2); }
.ledger dt { font-size: 0.93rem; }
.ledger dd { margin: 0; font-weight: 600; color: var(--ink); }
.ledger .total { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.ledger .total dt, .ledger .total dd { font-weight: 700; color: var(--ink); }
.ledger .total.neg dd { color: var(--serious-ink); }

/* ===== Meter (Makros) ===== */
.meters { display: grid; gap: 12px; }
.meters.compact { gap: 10px; margin-top: 12px; }
.meter-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.92rem; margin-bottom: 5px; color: var(--ink-2); }
.meter-value { font-variant-numeric: tabular-nums; color: var(--muted); }
.meter-value b { color: var(--ink); }
.meter-bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 99px; background: var(--mc, var(--muted)); transition: width 0.5s ease; }
.meter.s1 { --mc: var(--s1); }
.meter.s2 { --mc: var(--s2); }
.meter.s3 { --mc: var(--s3); }
.meter.s1 .meter-bar { background: color-mix(in srgb, var(--s1) 16%, var(--surface)); }
.meter.s2 .meter-bar { background: color-mix(in srgb, var(--s2) 16%, var(--surface)); }
.meter.s3 .meter-bar { background: color-mix(in srgb, var(--s3) 16%, var(--surface)); }
.meter.neutral { --mc: var(--ink-2); }
.meter.over { --mc: var(--serious); }
.more-nutrients { margin-top: 12px; }
details > summary { cursor: pointer; color: var(--ink-2); font-size: 0.92rem; list-style: none; display: flex; align-items: center; gap: 6px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.2s; margin: 0 4px 0 2px; }
details[open] > summary::before { transform: rotate(45deg); }

.status-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 600; margin-top: 4px; }
.status-tag.serious { color: var(--serious-ink); }
.status-tag.serious .icon { color: var(--serious); }
.status-tag.good { color: var(--good-ink); }

/* ===== Mahlzeiten & Listen ===== */
.meal { padding: 12px 8px 8px 16px; }
.meal-head { display: flex; align-items: center; gap: 8px; padding-right: 4px; min-height: 40px; }
.meal-head h2 { font-size: 1.08rem; font-weight: 650; flex: 1; display: flex; align-items: center; gap: 8px; }
.meal-head h2::before { content: ''; width: 4px; height: 18px; border-radius: 4px; background: var(--accent-mark); }
.meal-kcal { color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.meal-empty { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px 0 6px; }
p.meal-empty { padding: 0 8px 8px 0; margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.list-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; padding: 10px 8px 10px 0; min-height: 56px; border-radius: 10px;
}
button.list-item:active { background: var(--surface-2); }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li-title { font-weight: 550; display: flex; gap: 5px; align-items: center; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 0.83rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-value { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.li-value small { font-weight: 500; color: var(--muted); }
.li-delta { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.li-icon { color: var(--serious); }
.list-row { display: flex; align-items: center; gap: 2px; }
.list-row .list-item { flex: 1; min-width: 0; width: auto; }
.list-card { padding: 4px 8px 4px 8px; }
.fav { color: var(--ink-2); }
.fav-toggle { color: var(--muted); }
.fav-toggle.on { color: var(--ink-2); }
.empty-inline { padding: 18px 8px; color: var(--muted); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state { text-align: center; padding: 32px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--ink-2); }
.empty-state.small { padding: 18px 16px; }
.pad { padding: 14px 8px; }

.weight-quick { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 16px; }
.weight-quick > span { display: flex; align-items: center; gap: 8px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 0;
  font-weight: 650; text-decoration: none; transition: transform 0.08s, background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-ghost { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--critical); color: #fff; }
.btn-ghost.danger { color: var(--critical); }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 0 14px; border-radius: 12px; font-size: 0.93rem; }
.btn:disabled { opacity: 0.6; cursor: default; }
.is-busy { position: relative; color: transparent !important; }
.is-busy::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--on-accent); border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.btn-ghost.is-busy::after, .icon-btn.is-busy::after, .link-btn.is-busy::after, .menu-item.is-busy::after { border-color: var(--ink-2); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.btn-row .btn { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink); flex: none; text-decoration: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.small { width: 40px; height: 40px; color: var(--muted); }
.icon-btn.accent { background: var(--accent-soft); color: var(--accent-ink); width: 38px; height: 38px; }
.date-nav .icon-btn { background: var(--surface); border: 1px solid var(--line); }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 8px 6px;
  color: var(--accent-ink); font-weight: 600; text-decoration: none; border-radius: 10px; min-height: 40px;
}
.link-btn.muted { color: var(--muted); font-weight: 500; }
.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font-size: 0.9rem; text-decoration: none;
}
.chip:active { background: var(--surface-3); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.round-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2);
  display: grid; place-items: center; flex: none;
}

.fab {
  position: fixed; z-index: 15; right: max(16px, calc(50% - 264px));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 22px);
  width: 60px; height: 60px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 18px rgba(46, 125, 50, 0.35);
}
.fab:active { transform: scale(0.95); }

/* ===== Formulare ===== */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-size: 0.88rem; font-weight: 600; color: var(--ink-2); padding: 0; }
input:not([type='radio']):not([type='checkbox']), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); font-size: 16px; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.4; }
input:focus, textarea:focus, select:focus { border-color: var(--accent-mark); background: var(--surface); }
input[type='search'] { -webkit-appearance: none; appearance: none; }
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit input { padding-right: 52px; font-variant-numeric: tabular-nums; }
.input-unit > span { position: absolute; right: 14px; color: var(--muted); font-size: 0.9rem; pointer-events: none; }
.input-unit.big input { font-size: 1.5rem; font-weight: 650; text-align: center; padding-right: 70px; padding-left: 20px; min-height: 56px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form-error {
  margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.92rem;
  background: color-mix(in srgb, var(--critical) 12%, var(--surface)); color: var(--critical);
}
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 0.9rem; color: var(--ink-2); margin: 10px 0 0; }
.note .icon { margin-top: 1px; color: var(--accent-ink); }
.note.warn .icon { color: var(--serious); }
.parse-result.ok { color: var(--good-ink); }
.parse-result.warn { color: var(--serious-ink); }
.paste-box { display: flex; flex-direction: column; gap: 10px; }
.paste-area { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.paste-area textarea { background: var(--surface); }
.paste-area .btn-row { margin: 0; }
.paste-area .btn-ghost { background: var(--surface); border: 1px solid var(--line); }
.range-row { display: flex; }
.range-row .segmented { flex: 1; }

/* Segmented control */
.segmented {
  display: flex; background: var(--surface-2); border-radius: 14px; padding: 3px; gap: 2px; border: 1px solid var(--line);
}
.segmented > a, .segmented > button, .segmented > label {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 40px; border-radius: 11px; border: 0; background: none; text-decoration: none;
  color: var(--ink-2); font-weight: 600; font-size: 0.92rem; cursor: pointer; padding: 0 8px; position: relative;
  white-space: nowrap;
}
.segmented > label > input { position: absolute; opacity: 0; pointer-events: none; }
.segmented > label > span { display: block; }
.segmented > .active, .segmented > label:has(input:checked) {
  background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.segmented > label:has(input:focus-visible) { outline: 2px solid var(--accent-mark); }
.segmented.small > * { min-height: 34px; font-size: 0.84rem; padding: 0 8px; }
.meal-seg { margin-bottom: 12px; }

.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
}
.choice input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.choice span { display: flex; flex-direction: column; }
.choice small { color: var(--muted); }
.choice:has(input:checked) { border-color: var(--accent-mark); background: var(--accent-soft); }

.search-field {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.search-field input { border: 0 !important; background: transparent !important; padding-left: 0 !important; color: var(--ink); }
.sheet .search-field { background: var(--surface-2); margin-bottom: 4px; }

/* Key-Value-Liste */
.kv { display: grid; gap: 0; margin: 4px 0 0; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.kv.small { margin-top: 14px; font-size: 0.9rem; }

/* Nährwert-Tabelle (wie auf Rezeptseiten) */
.nutrition-table { margin: 8px 0 0; }
.nt-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.nt-row dt { color: var(--ink); }
.nt-row dd { margin: 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nt-row.nt-sub dt { padding-left: 14px; color: var(--ink-2); }

/* Mengen-Auswahl */
.amount { display: flex; flex-direction: column; gap: 14px; }
.amount-title { font-size: 1.3rem; }
.qty-row { display: flex; align-items: center; gap: 10px; }
.qty-row .input-unit { flex: 1; }
.amount-preview { text-align: center; }
.amount-preview details { text-align: left; margin-top: 8px; }
.macro-pills { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; font-size: 0.9rem; color: var(--ink-2); }
.macro-pills span { display: inline-flex; align-items: center; gap: 6px; }
.macro-pills b { color: var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.s1 { background: var(--s1); }
.dot.s2 { background: var(--s2); }
.dot.s3 { background: var(--s3); }

/* ===== Gewicht & Statistik ===== */
.stat-row { display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.stat-value small { font-size: 0.9rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.progress { height: 10px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; margin-top: 16px; }
.progress i { display: block; height: 100%; background: var(--accent-mark); border-radius: 99px; }
.progress-legend { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.progress-legend b { color: var(--ink); }
.bmi { display: flex; align-items: center; gap: 20px; }
.bmi > div { display: flex; flex-direction: column; }
.bmi p { margin: 0; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; }
.tile.wide { grid-column: 1 / -1; }
.tile .small .icon { display: inline; vertical-align: -2px; color: var(--good-ink); }

.chart { position: relative; width: 100%; min-height: 220px; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .ref { stroke: var(--ink-2); stroke-width: 1; opacity: 0.55; }
.chart .ref-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.chart .line { fill: none; stroke: var(--accent-mark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-mark); opacity: 0.1; }
.chart .dot { fill: var(--accent-mark); stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; }
.chart .bar { fill: var(--accent-mark); }
.chart .bar.over { fill: var(--serious); }
.chart .band-hl { fill: var(--ink); opacity: 0.05; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: var(--bg);
  padding: 6px 10px; border-radius: 10px; font-size: 0.82rem; white-space: nowrap; line-height: 1.35;
}
.chart-tip strong { font-size: 0.95rem; }
.chart-tip small { opacity: 0.75; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--ink-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .icon { color: var(--serious); }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.accent { background: var(--accent-mark); }
.swatch.over { background: var(--serious); }
.swatch.line { height: 2px; width: 14px; background: var(--ink-2); opacity: 0.6; border-radius: 0; }
.segbar { display: flex; gap: 2px; height: 14px; border-radius: 99px; overflow: hidden; margin: 4px 0 12px; }
.segbar i { display: block; height: 100%; min-width: 2px; }
.segbar .s1 { background: var(--s1); }
.segbar .s2 { background: var(--s2); }
.segbar .s3 { background: var(--s3); }
.macro-legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.macro-legend li { display: grid; grid-template-columns: 14px 1fr auto 3.2em; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.macro-legend li > .small { grid-column: 2 / -1; margin-top: -6px; }
.table-wrap { overflow-x: auto; margin-top: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th { color: var(--muted); font-weight: 600; }

/* ===== Profil-Menü ===== */
.menu { padding: 8px 8px 8px 16px; }
.menu .card-title { margin: 8px 0 4px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 8px 8px 0;
  background: none; border: 0; border-top: 1px solid var(--line); text-align: left; color: var(--ink); text-decoration: none;
}
.card-title + .menu-item, .menu > .menu-item:first-child { border-top: 0; }
.menu-item > span { flex: 1; }
.menu-item > .icon:first-child { color: var(--ink-2); }
.menu-item > .icon:last-child:not(:first-child) { color: var(--muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--critical) !important; }
.menu-item.static { cursor: default; flex-wrap: wrap; }
.menu-item .segmented { flex: none; }
.steps { padding-left: 1.2em; display: grid; gap: 8px; }

/* ===== Anmeldung ===== */
.auth { display: flex; flex-direction: column; gap: 16px; }
.auth-brand { text-align: center; align-items: center; gap: 6px; padding-top: calc(env(safe-area-inset-top) + 9vh); padding-bottom: 34px; }
.auth-brand img { border-radius: 20px; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 10px 30px rgba(0, 0, 0, 0.18); margin-bottom: 8px; }
.auth-brand h1 { font-size: 2.1rem; }
.auth-brand p { color: var(--hero-ink-2); margin: 0; }
.auth > .segmented { margin-top: -38px; position: relative; z-index: 1; background: var(--surface); box-shadow: var(--shadow); }
.goal-preview .kv { margin-top: 8px; }

/* ===== Tab-Leiste ===== */
.tabbar {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(540px, calc(100% - 20px)); height: var(--tabbar-h);
  display: flex; padding: 5px; gap: 2px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--line); border-radius: 34px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}
.tab {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 28px; color: var(--ink-2); text-decoration: none; font-size: 0.7rem; font-weight: 600;
}
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.active { background: var(--accent-soft); color: var(--accent-ink); }

/* ===== Bottom-Sheet ===== */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.22s; }
.sheet {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
  background: var(--surface); border-radius: 24px 24px 0 0; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); outline: none;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.sheet-tall { height: calc(100dvh - env(safe-area-inset-top) - 24px); }
.sheet-wrap.show .sheet-backdrop { opacity: 1; }
.sheet-wrap.show .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 99px; background: var(--surface-3); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 6px 20px; }
.sheet-head h2 { flex: 1; font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { overflow-y: auto; padding: 4px 20px 24px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; flex: 1; }
.sheet .tabs { margin-bottom: 12px; }
.sheet .list-item { padding-right: 4px; }
@media (min-width: 640px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 24px; max-height: min(86vh, 820px); }
  .sheet.sheet-tall { height: min(86vh, 820px); }
  .sheet-grip { display: none; }
}

/* ===== Toast ===== */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translate(-50%, 160%); opacity: 0; pointer-events: none; display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: 0.92rem; font-weight: 550;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); transition: transform 0.25s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
body.has-tabbar .toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 22px); }
body.sheet-open .toast { bottom: auto; top: calc(env(safe-area-inset-top) + 12px); transform: translate(-50%, -160%); }
body.sheet-open .toast.show { transform: translate(-50%, 0); }
.toast-info { background: var(--accent); color: #ffffff; }
.toast-info .icon { color: #ffffff; }
.toast-error .icon { color: var(--serious); }

@media (max-width: 380px) {
  .summary { grid-template-columns: 1fr; justify-items: center; }
  .summary .ledger { width: 100%; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .stat-value { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
