/* Fitness Tracker – mobile first, dunkles Design, Akzent #ed6e2b. Keine externen Schriften. */
:root {
  --bg: #121212;
  --surface: #1c1c1f;
  --surface-2: #26262b;
  --surface-3: #303036;
  --line: #3a3a41;
  --text: #f3f3f5;
  --muted: #a3a3ad;
  --accent: #ed6e2b;
  --accent-strong: #ff8442;
  --accent-soft: rgba(237, 110, 43, 0.16);
  --ok: #3ecf8e;
  --ok-soft: rgba(62, 207, 142, 0.15);
  --warn: #f5c542;
  --warn-soft: rgba(245, 197, 66, 0.15);
  --danger: #ff5a5f;
  --danger-soft: rgba(255, 90, 95, 0.15);
  --info: #6ea8fe;
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 48px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

a { color: var(--accent-strong); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.boot { padding: 40px 20px; text-align: center; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- Layout */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(18, 18, 18, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { flex: 1; font-weight: 700; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { min-width: var(--tap); }
main.view { padding: 16px 16px calc(var(--nav-h) + 110px + var(--safe-b)); max-width: 760px; margin: 0 auto; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #161618; border-top: 1px solid var(--line);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 600;
}
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a.active { color: var(--accent); }

/* ---------------------------------------------------------------- Sync-Status */
.sync-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 0.78rem; font-weight: 600; color: var(--muted); background: var(--surface);
  min-height: 34px; cursor: pointer;
}
.sync-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.sync-chip.ok { color: var(--ok); }
.sync-chip.pending { color: var(--warn); }
.sync-chip.syncing { color: var(--info); }
.sync-chip.error { color: var(--danger); }
.banner {
  margin: 0 0 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
}
.banner.warn { border-color: var(--warn); background: var(--warn-soft); }
.banner.error { border-color: var(--danger); background: var(--danger-soft); }
.banner.ok { border-color: var(--ok); background: var(--ok-soft); }
.banner .actions { margin-top: 10px; }

/* ---------------------------------------------------------------- Karten/Listen */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card.accent { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat .v { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 0.78rem; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 2px;
  color: inherit; text-decoration: none; width: 100%; background: none; border: 0; text-align: left; font: inherit; cursor: pointer;
}
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 0.85rem; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  background: var(--surface-3); color: var(--muted); white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: rgba(110, 168, 254, 0.15); color: var(--info); }
.kind-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--accent); }
.kind-dot.swim { background: var(--info); }
.kind-dot.cardio { background: var(--ok); }

/* ---------------------------------------------------------------- Buttons/Formulare */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-strong); }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; }
.btn.big { min-height: 64px; font-size: 1.1rem; width: 100%; }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 0.88rem; }
.btn.icon { padding: 0; width: var(--tap); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions.stack { flex-direction: column; }
.actions.stack .btn { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.field-error { color: var(--danger); font-size: 0.85rem; margin-top: 4px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg { display: flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-weight: 650; cursor: pointer; }
.seg button.active { background: var(--surface-3); color: var(--text); }

/* ---------------------------------------------------------------- Training */
.start-grid { display: grid; gap: 10px; }
.start-grid .btn { justify-content: flex-start; min-height: 60px; font-size: 1.02rem; }
.ex-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px; width: 100%; color: inherit; font: inherit; text-align: left; cursor: pointer; min-height: 64px; }
.ex-card .status { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.ex-card.started .status { border-color: var(--accent); background: var(--accent-soft); }
.ex-card.completed .status { border-color: var(--ok); background: var(--ok); }
.ex-card.skipped { opacity: 0.6; }
.ex-card.skipped .status { border-style: dashed; }
.ex-card.optional { border-style: dashed; }

.sets { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.set-row {
  display: grid; grid-template-columns: 30px minmax(0, 1.3fr) minmax(0, 1fr) 50px; gap: 6px; align-items: center;
  padding: 10px 8px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.set-row.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); background: linear-gradient(90deg, var(--accent-soft), var(--surface) 60%); }
.set-row.done { background: var(--surface-2); border-color: transparent; }
.set-row.warmup .idx { color: var(--info); }
.set-row .idx { font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; padding: 0; min-height: 52px; flex-direction: column; gap: 0; border: 0; font-size: 1.05rem; }
.set-row .idx small { display: block; font-size: 0.65rem; font-weight: 700; color: var(--muted); }
.stepper { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; align-items: center; gap: 3px; }
.stepper button { min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-3); color: var(--text); font-size: 1.25rem; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.stepper input { text-align: center; font-size: 1.05rem; font-weight: 700; padding: 6px 0; min-height: 44px; font-variant-numeric: tabular-nums; min-width: 0; }
.stepper .unit { grid-column: 1 / -1; text-align: center; font-size: 0.68rem; color: var(--muted); margin-top: -2px; }
.confirm-btn { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--accent); background: transparent; color: var(--accent); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.confirm-btn svg { width: 26px; height: 26px; }
.set-row.done .confirm-btn { background: var(--ok); border-color: var(--ok); color: #0c2a1c; }
.set-row .sync-state { grid-column: 1 / -1; font-size: 0.72rem; color: var(--muted); display: flex; gap: 8px; justify-content: space-between; }
.set-row .sync-state .pending { color: var(--warn); }
.set-row .sync-state .synced { color: var(--ok); }
.hint { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 0.88rem; margin-bottom: 10px; }

/* ---------------------------------------------------------------- Pausentimer */
.rest-timer {
  position: fixed; left: 8px; right: 8px; z-index: 25;
  bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
  max-width: 744px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 10px 12px; border-radius: var(--radius); border: 2px solid var(--accent);
  background: #201712; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.rest-timer .time { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.rest-timer .label { font-size: 0.78rem; color: var(--muted); }
.rest-timer .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.rest-timer .bar > div { height: 100%; background: var(--accent); width: 100%; }
.rest-timer.finished { border-color: var(--ok); background: #0f2219; }
.rest-timer.finished .time { color: var(--ok); }
.rest-timer.finished .bar > div { background: var(--ok); }
.rest-timer .actions .btn { min-height: 42px; padding: 0 10px; }

/* ---------------------------------------------------------------- Diagramme/Kalender */
.chart-box { position: relative; height: 220px; margin-top: 8px; }
.chart-box.tall { height: 260px; }
.empty { padding: 24px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar .dow { font-size: 0.72rem; color: var(--muted); text-align: center; padding: 4px 0; }
.calendar .day { min-height: 52px; padding: 4px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 0.8rem; display: flex; flex-direction: column; gap: 3px; color: inherit; font: inherit; cursor: pointer; }
.calendar .day.out { visibility: hidden; }
.calendar .day.today { border-color: var(--accent); }
.calendar .day .dots { display: flex; gap: 3px; flex-wrap: wrap; }
.calendar .day.selected { background: var(--surface-3); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th, table.data td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.data td.r, table.data th.r { text-align: right; font-variant-numeric: tabular-nums; }
.photo { max-width: 100%; border-radius: var(--radius-sm); display: block; margin: 8px 0; }

/* ---------------------------------------------------------------- Dialoge/Toasts */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-top-left-radius: 18px; border-top-right-radius: 18px;
  padding: 18px 16px calc(18px + var(--safe-b)); border: 1px solid var(--line);
}
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.toasts { position: fixed; left: 0; right: 0; top: calc(64px + var(--safe-t)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; max-width: 560px; width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--line); font-weight: 600; }
.toast.error { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

/* ---------------------------------------------------------------- Login */
.login { max-width: 400px; margin: 10vh auto 0; padding: 0 20px; }
.login .logo { width: 64px; height: 64px; margin-bottom: 16px; }

.gap { height: 12px; }
details.card > summary { cursor: pointer; font-weight: 650; min-height: 32px; }
details.card[open] > summary { margin-bottom: 10px; }

.sets + div p.muted { margin-top: 10px; }
@media (min-width: 480px) { .set-row { grid-template-columns: 40px minmax(0, 1.3fr) minmax(0, 1fr) 56px; gap: 10px; padding: 10px; } .stepper { grid-template-columns: 42px minmax(0, 1fr) 42px; } .confirm-btn { width: 52px; height: 52px; } }

/* Kopfzeile auf schmalen Displays: Status darf umbrechen statt den Titel zu verdrängen */
.topbar .title { min-width: 30%; }
.topbar .sync-chip { max-width: 56%; white-space: normal; line-height: 1.15; text-align: left; font-size: 0.74rem; }
main.view > h2 { margin-top: 22px; }
html { scroll-padding-bottom: calc(var(--nav-h) + 120px + var(--safe-b)); scroll-padding-top: 72px; }
