/* Kalorien-App – dunkles Design, fürs Handy gemacht */
:root {
  --bg: #0E1113;
  --surface: #171B1F;
  --surface-2: #1F252A;
  --line: #2A3137;
  --text: #ECEFF1;
  --text-2: #C5CCD2;
  --muted: #9AA4AD;
  --accent: #7BD88F;
  --accent-ink: #0E1113;
  --protein: #6FA8FF;
  --carbs: #F2A65A;
  --fat: #C792EA;
  --danger: #FF8A80;
  --warn-bg: #2E2614;
  --warn: #F5C26B;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.has-nav { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.wrap {
  max-width: 560px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-2); }
p { margin: 0; }
a { color: var(--accent); }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.icon { flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Formulare */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; min-height: 48px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea.code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-size: 13px; color: var(--text-2); margin-bottom: 8px; padding: 0; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 15px; color: var(--text); min-height: 44px; }
label.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }

/* Auswahl zum Antippen */
.choices { display: flex; gap: 8px; }
.choices > legend { width: 100%; }
.wrap-choices { flex-wrap: wrap; }
.choice { flex: 1 1 0; min-width: 0; position: relative; }
.pick { position: relative; }
.choice input, .pick input, .toggle input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px; padding: 4px 8px;
  border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); font-size: 15px; font-weight: 500; cursor: pointer; line-height: 1.2;
}
.wrap-choices .choice { flex: 1 1 auto; }
.wrap-choices .choice span { padding: 4px 14px; }
.choice input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.choice input:focus-visible + span, .pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset:disabled .choice span { opacity: 0.55; cursor: not-allowed; }

.cards { display: flex; flex-direction: column; gap: 8px; }
.pick > span {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: 15px; cursor: pointer;
}
.pick input:checked + span { background: #1A2620; }
.pick input:checked + span { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.toggles { display: flex; flex-direction: column; }
.toggle {
  flex-direction: row; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--surface-2); color: var(--text); font-size: 15px;
}
.toggle:last-child { border-bottom: 0; }
.toggle input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 52px; height: 32px; min-height: 0; flex: 0 0 auto;
  border-radius: 16px; background: var(--line); border: 0; padding: 0; position: relative; cursor: pointer;
}
.toggle input[type="checkbox"]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--text); transition: transform .15s;
}
.toggle input[type="checkbox"]:checked { background: var(--accent); }
.toggle input[type="checkbox"]:checked::after { transform: translateX(20px); background: var(--accent-ink); }

.slider { display: flex; flex-direction: column; gap: 8px; }
.slider label { display: block; color: var(--text); font-size: 15px; }
input[type="range"] { padding: 0; min-height: 44px; background: transparent; border: 0; accent-color: var(--accent); }
.scale { display: flex; justify-content: space-between; }

/* Knöpfe */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border-color: #4A2A28; }
.btn-block { width: 100%; }
.btn:focus-visible, .iconbtn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.iconbtn {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 12px; border: 0;
  background: var(--surface-2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.iconbtn:disabled { opacity: 0.35; cursor: default; }
.iconbtn.danger { color: var(--danger); }

/* Meldungen */
.flash { padding: 12px 14px; border-radius: 12px; font-size: 14px; background: #183322; color: #B9F0C6; }
.flash-fehler { background: #3A2422; color: #FFC2BC; }
.warning {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: var(--warn-bg); color: var(--warn); font-size: 14px;
}
.warning p + p { margin-top: 6px; }
.notice { display: flex; gap: 12px; align-items: center; color: var(--text); text-decoration: none; border: 1px solid var(--accent); }
.notice .icon { color: var(--accent); }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); }
.badge-off { background: #3A2422; color: #FFC2BC; }

/* Seitenkopf */
.pagehead { display: flex; flex-direction: column; gap: 4px; position: relative; }
.pagehead .back { margin-bottom: 6px; }
.back {
  width: 44px; height: 44px; border-radius: 22px; background: var(--surface);
  color: var(--text); display: inline-flex; align-items: center; justify-content: center;
}
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.daynav > a {
  width: 44px; height: 44px; border-radius: 22px; background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}
.daynav .center { display: flex; flex-direction: column; align-items: center; }

/* Tagesübersicht */
.summary { display: flex; align-items: center; gap: 20px; }
.ring { position: relative; width: 140px; height: 140px; flex: 0 0 auto; }
.ring-bg { fill: none; stroke: #262D33; stroke-width: 14; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 14; stroke-linecap: round; }
.ring-fg.over { stroke: var(--carbs); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label strong { font-size: 30px; font-weight: 700; }
.summary-side { display: flex; flex-direction: column; gap: 12px; }
.summary-side div { display: flex; flex-direction: column; }
.summary-side strong { font-size: 18px; font-weight: 600; }

.macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.macro { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.macro strong { font-size: 14px; font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 4px; margin-right: 6px; vertical-align: 1px; }
.dot-p { background: var(--protein); } .dot-c { background: var(--carbs); } .dot-f { background: var(--fat); }
progress.bar { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border: 0; border-radius: 3px; background: #262D33; overflow: hidden; }
progress.bar::-webkit-progress-bar { background: #262D33; border-radius: 3px; }
progress.bar::-webkit-progress-value { border-radius: 3px; }
progress.bar-p::-webkit-progress-value { background: var(--protein); } progress.bar-p::-moz-progress-bar { background: var(--protein); }
progress.bar-c::-webkit-progress-value { background: var(--carbs); } progress.bar-c::-moz-progress-bar { background: var(--carbs); }
progress.bar-f::-webkit-progress-value { background: var(--fat); } progress.bar-f::-moz-progress-bar { background: var(--fat); }

.meals { display: flex; flex-direction: column; gap: 10px; }
.meal { padding: 8px 8px 8px 16px; }
.meal-head { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.entry {
  display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 0; margin-right: 0;
  border-top: 1px solid var(--surface-2); color: var(--text); text-decoration: none; font-size: 15px;
}
.empty { padding: 4px 0 8px; }

/* Listen und Menüs */
.list { padding: 4px 16px; }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--surface-2); color: var(--text); text-decoration: none; }
.row:last-child { border-bottom: 0; }
.slot-row { gap: 6px; padding: 8px 0; }
.inline-form input { min-height: 44px; }
.menu { padding: 4px 16px; display: flex; flex-direction: column; }
.menu a { display: flex; align-items: center; gap: 14px; min-height: 56px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--surface-2); }
.menu a:last-child { border-bottom: 0; }
.menu a span { flex: 1 1 auto; }
.menu a .icon:first-child { color: var(--accent); }
details summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; min-height: 28px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: 14px; }
.helper summary { font-weight: 500; color: var(--text-2); font-size: 15px; }
.helper .btn { margin-top: 12px; }
.danger-zone { margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips form { display: contents; }
.chip {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; max-width: 100%;
}

/* Rechner-Ergebnis */
.result { display: flex; flex-direction: column; gap: 14px; }
.result-main { display: flex; flex-direction: column; align-items: center; }
.big { font-size: 44px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.result-grid div { display: flex; flex-direction: column; gap: 2px; }
.result-grid strong { font-size: 16px; }

/* Anmeldung */
.login { display: flex; flex-direction: column; gap: 20px; padding-top: 8vh; }
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 24px; font-weight: 700; color: var(--accent); }

/* Untere Navigation */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 0;
  background: #12161A; border-top: 1px solid var(--surface-2);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1 1 0; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; min-height: 52px; font-size: 12px; color: var(--muted); text-decoration: none;
}
.tabbar a.active { color: var(--accent); }

@media (max-width: 360px) {
  .summary { gap: 14px; }
  .ring, .ring svg { width: 120px; height: 120px; }
  .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
