/* ------------------------------------------------------------ Schrift */
@font-face { font-family: Nunito; font-style: normal; font-weight: 400;
  src: url(/fonts/nunito-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: Nunito; font-style: normal; font-weight: 600;
  src: url(/fonts/nunito-latin-600-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: Nunito; font-style: normal; font-weight: 700;
  src: url(/fonts/nunito-latin-700-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: Nunito; font-style: normal; font-weight: 800;
  src: url(/fonts/nunito-latin-800-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: Nunito; font-style: normal; font-weight: 900;
  src: url(/fonts/nunito-latin-900-normal.woff2) format('woff2'); font-display: swap; }

:root {
  --bg: #000;
  --card: #131315;
  --card2: #1c1c1f;
  --line: #232326;
  --text: #fff;
  --muted: #8b8b90;
  --dim: #58585d;
  --green: #34d861;
  --green-soft: rgba(52, 216, 97, .14);
  --over: #ff5f6d;
  --protein: #4c9dff;
  --carbs: #f5b73d;
  --fat: #a97bff;
  --r: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: Nunito, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; overscroll-behavior-y: none; }
body { position: fixed; inset: 0; }
button, input, select { font-family: inherit; font-size: 16px; }
button { cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small-text { font-size: 13.5px; line-height: 1.6; }
.spacer { height: 48px; }
svg.stroke { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }

/* ------------------------------------------------------------ Login */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 26px; background: #000; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-logo { width: 84px; height: 84px; border-radius: 22px; margin-bottom: 20px; }
.login-box h1 { font-size: 26px; font-weight: 900; letter-spacing: 1px; margin: 0 0 6px; }
.login-box p { margin: 0 0 24px; font-size: 14px; }
.login-box input { width: 100%; padding: 16px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); margin-bottom: 12px; outline: none; text-align: center; }
.login-box input:focus { border-color: #3a3a3f; }
.error { color: var(--over); font-size: 14px; margin-top: 14px; min-height: 20px; font-weight: 600; }

/* ------------------------------------------------------------ Gerüst */
.app { position: fixed; inset: 0; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 0;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }

/* Kopfbereich: eine Fläche mit abgerundeter Unterkante, wie in der Vorlage */
.head { background: #0b0b0c; border-bottom: 1px solid var(--line);
  border-radius: 0 0 24px 24px; padding: calc(12px + var(--safe-t)) 16px 12px; flex: 0 0 auto; z-index: 3; }
.head-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.head-row h1 { font-size: 23px; font-weight: 900; letter-spacing: .6px; margin: 0; flex: 1; }
.head-right { display: flex; align-items: center; gap: 6px; }
.ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--text); }
.ico svg { width: 21px; height: 21px; }
.ico:active { background: var(--card2); }
.streak { display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px; }
.streak .flame { width: 20px; height: 22px; fill: var(--green); stroke: none; }
.streak b { font-size: 16px; font-weight: 800; }

.datebar { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; }
.datebar span { flex: 1; font-size: 15px; color: var(--muted); font-weight: 600; }
.wknav { width: 30px; height: 30px; border-radius: 10px; color: var(--muted); font-size: 20px; line-height: 1; }
.wknav:active { background: var(--card2); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 2px 0; }
.wd em { font-style: normal; font-size: 13.5px; color: var(--dim); font-weight: 600; }
.wd i { font-style: normal; font-size: 16px; font-weight: 700; color: var(--muted);
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.wd.today i { color: var(--text); }
.wd.on em { color: var(--text); }
.wd.on i { background: #fff; color: #000; font-weight: 800; }
.wd .dotrow { height: 5px; display: flex; gap: 3px; align-items: center; }
.wd .dotrow s { width: 5px; height: 5px; border-radius: 50%; background: var(--green); display: block; }

.sec { font-size: 11.5px; font-weight: 800; letter-spacing: 1.1px; color: var(--muted);
  margin: 20px 4px 9px; }

.card { background: var(--card); border-radius: var(--r); padding: 16px; }
.card + .card { margin-top: 10px; }
.card.list { padding: 0; overflow: hidden; }
.card.mini { text-align: center; padding: 18px 10px; }
.card.mini b { display: block; font-size: 22px; font-weight: 800; }
.card.mini small { color: var(--muted); font-size: 11.5px; }

/* ------------------------------------------------------------ Halbring */
.gauge { position: relative; padding-top: 4px; }
.gauge-svg { width: 100%; display: block; }
.arc-track { fill: none; stroke: #2a2a2e; stroke-width: 10; stroke-linecap: round; }
.arc-fill  { fill: none; stroke: var(--green); stroke-width: 10; stroke-linecap: round;
  transition: stroke-dashoffset .45s ease; }
.arc-fill.over { stroke: var(--over); }
.gauge-cols { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: space-between; }
.gcol { flex: 0 0 25%; text-align: center; }
.gcol b { display: block; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gcol small { font-size: 11.5px; color: var(--muted); }
.gcol.mid { position: absolute; left: 50%; transform: translateX(-50%); flex: 0 0 auto; }
.gcol.mid b { font-size: 30px; letter-spacing: -.5px; }
.gcol.mid small { font-size: 12.5px; }

.macros { display: flex; gap: 10px; margin-top: 4px; }
.mac { flex: 1; text-align: center; }
.mac span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mac .bar { height: 5px; background: #2a2a2e; border-radius: 3px; overflow: hidden; margin: 7px 0 6px; }
.mac .bar i { display: block; height: 100%; width: 0; border-radius: 3px; transition: width .45s ease; }
.mac small { font-size: 12px; color: var(--muted); }
[data-macro="protein"] .bar i { background: var(--protein); }
[data-macro="carbs"]   .bar i { background: var(--carbs); }
[data-macro="fat"]     .bar i { background: var(--fat); }

/* ------------------------------------------------------------ Mahlzeiten */
.card.meals { padding: 0; overflow: hidden; }
.meal + .meal { border-top: 1px solid var(--line); }
.meal-row { display: flex; align-items: center; gap: 13px; width: 100%; padding: 13px 15px; text-align: left; }
.meal-ring { position: relative; width: 42px; height: 42px; flex: 0 0 42px; }
.meal-ring svg.ring { position: absolute; inset: 0; width: 42px; height: 42px; transform: rotate(-90deg); }
.meal-ring svg.ring circle { fill: none; stroke-width: 2.5; }
.meal-ring .t { stroke: #2f2f34; }
.meal-ring .f { stroke: var(--green); transition: stroke-dashoffset .4s ease; }
.meal-ring em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; }
.meal-ring em svg { width: 21px; height: 21px; fill: none; stroke: #d8d8dc;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.meal-row .nm { flex: 1; min-width: 0; }
.meal-row .nm b { display: block; font-size: 16px; font-weight: 700; }
.meal-row .nm small { font-size: 12.5px; color: var(--muted); }
.plus { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid #3a3a40;
  display: grid; place-items: center; color: var(--text); font-size: 20px; line-height: 1; flex: 0 0 34px; }
.plus:active { background: var(--card2); }

.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 15px 9px 70px; text-align: left; }
.item:active { background: var(--card2); }
.item .info { flex: 1; min-width: 0; }
.item .info b { display: block; font-size: 14.5px; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.item .info small { color: var(--muted); font-size: 12px; }
.item .kc { font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.meal .pad-b { height: 6px; }

/* ------------------------------------------------------------ Gewicht */
.weight-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid #3a3a40;
  display: grid; place-items: center; font-size: 24px; line-height: 1; color: var(--text); flex: 0 0 46px; }
.round:active { background: var(--card2); }
.weight-val { flex: 1; display: flex; align-items: baseline; justify-content: center; gap: 3px; }
.weight-val input { width: 5.2ch; background: none; border: none; outline: none; color: var(--text);
  font-size: 30px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; padding: 0; }
.weight-val .kg { font-size: 24px; font-weight: 800; }
.hintline { font-size: 12px; color: var(--dim); text-align: center; margin: 8px 0 0; min-height: 16px; }
.warn { margin: 0; color: #ffc98a; line-height: 1.6; }
.warn b { color: #ffb45c; }
.warn code { background: #2a2118; padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }

/* ------------------------------------------------------------ Buttons / Felder */
.btn { padding: 15px 18px; border-radius: 999px; font-size: 15.5px; font-weight: 800; text-align: center; }
.btn.white { background: #f5f5f7; color: #000; }
.btn.dark { background: var(--card2); color: var(--text); }
.btn.danger { background: transparent; border: 1.5px solid #442027; color: var(--over); }
.btn.block { display: block; width: 100%; margin-top: 12px; }
.btn:active { opacity: .82; }
.linkbtn { color: var(--green); font-size: 15px; font-weight: 700; padding: 4px; }

.field { display: block; margin-bottom: 13px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select { width: 100%; padding: 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card2); color: var(--text); outline: none; appearance: none; font-weight: 600; }
.field input:focus, .field select:focus { border-color: #45454b; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid2 > .card { margin-top: 0; }

.searchwrap { margin-top: 12px; }
.searchwrap input { width: 100%; padding: 13px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); outline: none; font-weight: 600; }
.sheet .searchwrap { padding: 0 16px; }
.searchwrap input:focus { border-color: #45454b; }

/* ------------------------------------------------------------ Navigation */
.tabbar { position: absolute; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b));
  display: flex; background: #17171a; border: 1px solid #232326; border-radius: 22px;
  padding: 8px 4px; z-index: 6; box-shadow: 0 10px 30px rgba(0, 0, 0, .55); }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.tabbar button svg { width: 21px; height: 21px; }
.tabbar button span { font-size: 8.5px; font-weight: 800; letter-spacing: .3px; }
.tabbar button.on { color: var(--green); }

/* ------------------------------------------------------------ Listen */
.list-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 16px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--card2); }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info b { display: block; font-size: 15.5px; font-weight: 700; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.list-item .info small { color: var(--muted); font-size: 12.5px; }
.list-item .kc { font-size: 14px; color: var(--muted); text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.list-item .kc b { display: block; font-size: 15px; color: var(--text); font-weight: 700; }
.empty { padding: 18px 16px; color: var(--muted); font-size: 14px; }
.group { background: var(--card); border-radius: var(--r); overflow: hidden; margin-top: 12px; }

/* ------------------------------------------------------------ Statistik */
.subtabs { display: flex; gap: 22px; margin-top: 14px; }
.subtabs button { font-size: 16px; font-weight: 700; color: var(--muted); padding: 6px 0 8px; position: relative; }
.subtabs button.on { color: var(--text); }
.subtabs button.on::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0;
  height: 2.5px; border-radius: 2px; background: var(--green); }

.card-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.card-head > div:first-child { flex: 1; }
.card-head b { display: block; font-size: 17px; font-weight: 700; }
.card-head small { color: var(--muted); font-size: 13px; }
.card-head-val { font-size: 15px; font-weight: 800; text-align: right; white-space: nowrap; }
.card-head-val i { font-style: normal; font-weight: 700; color: var(--muted); font-size: 13px; }

.barchart { display: flex; align-items: flex-end; gap: 5px; height: 120px; position: relative; padding-top: 14px; }
.barchart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 2px; }
.barchart .col i { display: block; width: 100%; border-radius: 6px; background: var(--green); min-height: 3px; }
.barchart .col.over i { background: var(--over); }
.barchart .col.none i { background: #232327; }
.goalline { position: absolute; left: 0; right: 0; border-top: 1px dashed #3a3a40; pointer-events: none; }
.goalline b { position: absolute; right: 0; top: -16px; font-size: 10.5px; color: var(--muted);
  background: var(--card); padding: 0 4px; font-weight: 700; }
.axis { display: flex; gap: 3px; margin-top: 8px; }
.axis span { flex: 1; text-align: center; font-size: 10px; color: var(--dim); min-width: 3px;
  overflow: hidden; white-space: nowrap; }

.linechart { height: 108px; position: relative; }
.linechart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.linechart .ln { fill: none; stroke: var(--green); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.linechart .pt { fill: #000; stroke: var(--green); stroke-width: 2.5; }
.linechart .lbl { fill: var(--green); font-size: 9px; font-weight: 700; text-anchor: middle; }
.linechart .dy { fill: #58585d; font-size: 9px; text-anchor: middle; }
.nodata { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 14px; text-align: center; }

/* ------------------------------------------------------------ Sheets */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 20;
  display: flex; align-items: flex-end; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes up { from { transform: translateY(100%) } to { transform: translateY(0) } }
.sheet { width: 100%; max-height: 92vh; background: #141416; border-radius: 26px 26px 0 0;
  display: flex; flex-direction: column; animation: up .22s cubic-bezier(.25, .9, .3, 1);
  padding-bottom: var(--safe-b); }
.grabber { width: 44px; height: 4px; border-radius: 3px; background: #fff; opacity: .85;
  margin: 10px auto 2px; flex: 0 0 auto; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 12px 14px 14px; }
.sheet-head b { font-size: 16px; font-weight: 900; letter-spacing: .6px; }
.sheet-head .linkbtn { justify-self: start; }
.sheet-head-right { justify-self: end; }
.sheet-scroll { overflow-y: auto; flex: 1; min-height: 130px; }
.pad { padding: 4px 16px 16px; overflow-y: auto; }
.sheet-foot { padding: 10px 16px 16px; }

.segmented { display: flex; gap: 6px; padding: 0 16px 12px; }
.segmented button { flex: 1; padding: 11px; border-radius: 999px; font-size: 14px; font-weight: 700;
  color: var(--muted); background: var(--card2); }
.segmented button.on { background: #f5f5f7; color: #000; }

.picked { padding: 14px 16px; background: var(--card2); border-radius: 16px; margin-bottom: 14px; }
.picked b { display: block; font-size: 16.5px; font-weight: 700; margin-bottom: 3px; }
.picked small { color: var(--muted); font-size: 12.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: -3px 0 14px; }
.chips button { padding: 8px 13px; border-radius: 999px; background: var(--card2);
  border: 1.5px solid transparent; font-size: 13px; font-weight: 700; color: var(--muted); }
.chips button.on { border-color: var(--green); color: var(--green); }

.preview { display: flex; gap: 8px; padding: 14px; background: var(--card2); border-radius: 16px; margin-bottom: 14px; }
.preview div { text-align: center; flex: 1; }
.preview b { display: block; font-size: 18px; font-weight: 800; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.preview small { color: var(--muted); font-size: 11px; }

.mealpick { display: flex; gap: 6px; margin-bottom: 16px; }
.mealpick button { flex: 1; padding: 11px 4px; border-radius: 14px; background: var(--card2);
  border: 1.5px solid transparent; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.mealpick button.on { border-color: var(--green); color: var(--green); background: var(--green-soft); }

/* ------------------------------------------------------------ Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 24px);
  transform: translateX(-50%) translateY(18px); background: #2c2c31; color: #fff; padding: 12px 20px;
  border-radius: 999px; font-size: 14px; font-weight: 700; opacity: 0; pointer-events: none;
  transition: all .22s ease; z-index: 60; max-width: 88vw; text-align: center;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .6); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: #4a2026; color: #ffd7dc; }

@media (min-width: 720px) {
  .view, .tabbar { max-width: 520px; margin-left: auto; margin-right: auto; }
  .view { left: 0; right: 0; }
  .tabbar { left: 0; right: 0; width: calc(100% - 24px); }
  .sheet { max-width: 520px; margin: 0 auto; }
}
