/* Fitness-App – dunkles Design mit wählbarer Akzentfarbe (Einstellungen → Darstellung) */
:root {
  --accent: #4f7cff;
  --bg: #0d111c; --surface: #151b2b; --surface2: #1c2438; --line: #29324a;
  --fg: #e7ebf5; --muted: #95a0ba; --good: #34c98b; --warn: #ffb547; --bad: #ff6b6b;
  --radius: 14px; --gap: 14px;
  --nav-h: 64px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --surface: #ffffff; --surface2: #eef1f8; --line: #dde2ee;
  --fg: #141a2a; --muted: #5d6680; --good: #148a5a; --warn: #b86e00; --bad: #c93838;
  color-scheme: light;
}
:root.compact { --gap: 9px; --radius: 10px; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
body.no-scroll { overflow: hidden; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
small, .muted { color: var(--muted); }
#main { max-width: 860px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 14px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); display: grid; gap: var(--gap); }
.loading { color: var(--muted); padding: 30px; text-align: center; }

/* Navigation unten */
#nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; z-index: 20; }
#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 11px; }
#nav a .ico { font-size: 20px; filter: grayscale(.6); }
#nav a.active { color: var(--accent); }
#nav a.active .ico { filter: none; }
@media (min-width: 900px) {
  #nav { top: 0; bottom: 0; right: auto; width: 92px; height: auto; flex-direction: column; justify-content: flex-start; padding-top: 20px; border-top: 0; border-right: 1px solid var(--line); }
  #nav a { flex: 0 0 72px; }
  #main { padding-left: 110px; max-width: 980px; }
}

/* Karten & Layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.error { border-color: var(--bad); color: var(--bad); }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid3.collapse { grid-template-columns: 1fr; } }
.spacer { flex: 1; }
.hidden { display: none !important; }
.center { text-align: center; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

/* Kennzahlen */
.kpi { background: var(--surface2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.kpi .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: .85rem; font-weight: 500; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }

/* Buttons & Formulare */
.btn { font: inherit; border: 1px solid var(--line); background: var(--surface2); color: var(--fg); padding: 9px 14px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; min-height: 40px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.big { padding: 14px 20px; font-size: 1.05rem; width: 100%; }
.btn.icon { padding: 6px 10px; min-width: 40px; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; width: 100%; min-width: 0; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 40px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field-help { font-size: 12px; color: var(--muted); margin-top: -2px; }
form.stack, .stack { display: grid; gap: 12px; }

/* Ringe & Balken */
.ring { width: 140px; height: 140px; }
.ring-bg { fill: none; stroke: var(--surface2); stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .4s; }
.ring.over .ring-fg { stroke: var(--warn); }
.ring-val { fill: var(--fg); font-size: 24px; font-weight: 700; }
.ring-sub { fill: var(--muted); font-size: 11px; }
.bars { display: grid; gap: 10px; flex: 1; min-width: 180px; }
.bar-head { display: flex; justify-content: space-between; font-size: 13px; }
.bar { position: relative; height: 10px; background: var(--surface2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .4s; }
.bar-fill.ok { background: var(--good); }
.bar-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--fg); opacity: .4; }

/* Listen */
.list { display: grid; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 48px; }
.item:last-child { border-bottom: 0; }
.item .main { flex: 1; min-width: 0; }
.item .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 12px; color: var(--muted); }
.item .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.badge { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 6px; background: var(--surface2); color: var(--muted); font-weight: 700; }
.badge.own { color: var(--good); } .badge.off { color: #ff9f43; } .badge.bls { color: #4fc3f7; } .badge.usda { color: #b39ddb; } .badge.recipe { color: #f48fb1; }
.meal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 13px; padding: 5px 10px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--line); cursor: pointer; color: var(--fg); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs { display: flex; gap: 4px; background: var(--surface2); padding: 4px; border-radius: 11px; overflow-x: auto; }
.tabs button { font: inherit; flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--surface); color: var(--fg); font-weight: 600; }

/* Datumsleiste */
.datebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.datebar .d { font-weight: 600; text-align: center; flex: 1; }

/* Dialoge */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { position: relative; background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 12px; animation: up .18s ease-out; }
.modal.wide { max-width: 860px; }
@media (min-width: 700px) { .modal-wrap { align-items: center; } .modal { border-radius: 18px; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal-x { position: absolute; top: 10px; right: 10px; border: 0; background: var(--surface2); color: var(--fg); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; }
.modal h2 { padding-right: 36px; }
.confirm-text { font-size: 1.05rem; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--surface2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 60; transition: .2s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.ok { border-color: var(--good); } .toast.error { border-color: var(--bad); }

/* Scanner */
.scanner { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4/3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 25% 12%; border: 3px solid var(--accent); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

/* Diagramme */
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* Training */
.set-row { display: grid; grid-template-columns: 34px 1fr 1fr 46px; gap: 8px; align-items: center; padding: 6px 0; }
.set-row .no { color: var(--muted); font-weight: 700; text-align: center; }
.set-row input { text-align: center; padding: 8px 4px; }
.set-row .target { grid-column: 2 / 4; font-size: 11px; color: var(--muted); margin-top: -6px; text-align: center; }
.set-row.done input { border-color: var(--good); }
.check { width: 44px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); color: var(--muted); font-size: 18px; cursor: pointer; }
.check.on { background: var(--good); border-color: var(--good); color: #fff; }
.timer { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 30; max-width: 560px; margin: 0 auto;
  background: var(--accent); color: #fff; border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.timer .t { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; flex: 1; }
.timer button { background: rgba(255,255,255,.2); border: 0; color: #fff; border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; }
.ex-img { width: 100%; max-height: 220px; object-fit: contain; background: #fff; border-radius: 10px; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: contain; background: #fff; flex: none; }
.pe-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 8px; background: var(--surface2); }

/* Meilensteine */
.rail { list-style: none; margin: 0; padding: 0; }
.rail li { display: grid; grid-template-columns: 82px 16px 1fr; gap: 10px; padding: 8px 0; }
.rail .when { color: var(--muted); font-size: 13px; text-align: right; }
.rail .dot { position: relative; }
.rail .dot::before { content: ""; position: absolute; left: 7px; top: 0; bottom: -18px; width: 2px; background: var(--line); }
.rail li:last-child .dot::before { display: none; }
.rail .dot::after { content: ""; position: absolute; left: 2px; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); }
.rail li.done .dot::after { background: var(--accent); border-color: var(--accent); }
.rail li.reached .dot::after { background: var(--good); border-color: var(--good); }
.rail li.next .dot::after { background: var(--warn); border-color: var(--warn); }
.rail .what p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* Einstellungen */
.set-section summary { cursor: pointer; font-weight: 600; font-size: 1.02rem; padding: 4px 0; list-style: none; display: flex; justify-content: space-between; }
.set-section summary::after { content: '›'; transform: rotate(90deg); transition: .2s; color: var(--muted); }
.set-section[open] summary::after { transform: rotate(-90deg); }
.set-section .fields { display: grid; gap: 12px; margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.scroll-x { overflow-x: auto; }
pre.raw { white-space: pre-wrap; word-break: break-all; font-size: 11px; background: var(--bg); padding: 8px; border-radius: 8px; max-height: 240px; overflow: auto; }

/* Anmeldung */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 24px; width: 100%; max-width: 380px; text-align: center; display: grid; gap: 16px; }
.login .logo { font-size: 48px; }
.notice { background: var(--surface2); border-radius: 10px; padding: 12px; font-size: 14px; text-align: left; }
.notice.error { color: var(--bad); }
.notice.warn { border-left: 3px solid var(--warn); }
.notice.ok { border-left: 3px solid var(--good); }

/* Etiketten (Meal Prep) */
.label-sheet { display: grid; grid-template-columns: repeat(var(--cols), var(--lw)); grid-auto-rows: var(--lh); gap: 0; background: #fff; color: #000;
  padding: var(--mt) 0 0 var(--ml); width: max-content; max-width: 100%; overflow-x: auto; border-radius: 6px; }
.label { box-sizing: border-box; width: var(--lw); height: var(--lh); padding: 2.5mm 3mm; display: flex; gap: 2mm; overflow: hidden; outline: 1px dashed #ccc; font-size: 8.5pt; line-height: 1.25; }
.label .lt { flex: 1; display: flex; flex-direction: column; gap: .5mm; min-width: 0; }
.label .lt strong:first-child { font-size: 10pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .lq { width: calc(var(--lh) - 12mm); flex: none; display: flex; flex-direction: column; align-items: center; }
.label .lq svg { width: 100%; height: auto; }
.label .lq small { font-size: 6.5pt; letter-spacing: .05em; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  #nav, .no-print, .toast, .timer { display: none !important; }
  #main { padding: 0 !important; margin: 0 !important; max-width: none !important; display: block !important; }
  .label-sheet { border-radius: 0; overflow: visible; }
  .label { outline: none; }
}
