:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaf0;
  --muted: #949bab;
  --accent: #4ade80;
  --accent-dim: #16311f;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(96px + var(--safe-b)); }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0; }
small { color: var(--muted); }

.app { max-width: 620px; margin: 0 auto; padding: 14px 14px 24px; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0 16px;
}
.topbar .grow { flex: 1; min-width: 0; }
.topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Karten ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card-row { display: flex; align-items: center; gap: 12px; }
.card-tap { cursor: pointer; }
.card-tap:active { background: var(--surface-2); }

.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--muted); }
.tiny { font-size: 0.8rem; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 10px; }

/* ---------- Buttons ---------- */
button { font: inherit; color: inherit; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; font-weight: 600;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06210f; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: #3a2427; background: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.88rem; border-radius: 10px; }
.btn-icon {
  width: 40px; min-height: 40px; padding: 0; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 1.05rem; flex: none;
}

/* ---------- Formulare ---------- */
label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; appearance: none;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input::placeholder { color: #5c6474; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.field-sm input { min-height: 40px; padding: 6px 10px; text-align: center; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 0.74rem; color: var(--muted); white-space: nowrap;
}
.badge-accent { background: var(--accent-dim); border-color: #24512f; color: var(--accent); }
.badge-warn { color: var(--warn); border-color: #453413; background: #2a2211; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.tabs button {
  flex: 1; min-height: 38px; border: 0; background: transparent;
  border-radius: 9px; font-weight: 600; color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); }

/* ---------- Navigation unten ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b));
  background: rgba(15, 17, 21, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav button {
  flex: 1; border: 0; background: none; color: var(--muted);
  display: grid; gap: 2px; padding: 6px 0; font-size: 0.68rem; font-weight: 600;
}
.nav button span { font-size: 1.25rem; line-height: 1; }
.nav button[aria-current="page"] { color: var(--accent); }

/* ---------- Übungen im Training ---------- */
.ex { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.ex-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.ex-head .grow { min-width: 0; }
.ex-name { font-weight: 650; }
.ex-done { color: var(--accent); }

.set {
  display: grid;
  grid-template-columns: 30px 1fr 1fr 46px;
  gap: 8px; align-items: center;
  padding: 7px 14px;
  border-top: 1px solid var(--line);
}
.set-no { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.set-done { background: rgba(74, 222, 128, 0.06); }
.check {
  width: 46px; min-height: 40px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface-2);
  display: grid; place-items: center; font-size: 1.05rem; color: var(--muted);
}
.check[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #06210f; }
.set-hint {
  grid-column: 1 / -1; padding: 0 0 4px 30px;
  font-size: 0.76rem; color: var(--muted);
}
.ghost-val { color: #5c6474; }

.prev-box {
  padding: 8px 14px; border-top: 1px solid var(--line);
  background: var(--surface-2); font-size: 0.8rem; color: var(--muted);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.prev-box b { color: var(--text); font-weight: 600; }

/* ---------- Editor ---------- */
.ex-edit {
  display: grid; grid-template-columns: 1fr 62px 74px 40px;
  gap: 8px; align-items: end;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.ex-edit label { white-space: nowrap; overflow: hidden; }

/* ---------- Pausentracker ---------- */
.timer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #10161b;
  border-top: 1px solid #24523a;
  padding-bottom: var(--safe-b);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
}
.timer-bar { height: 4px; background: #1b2229; }
.timer-fill { height: 100%; width: 100%; background: var(--accent); transition: width 0.25s linear; }
.timer.warn .timer-fill { background: var(--warn); }
.timer.over .timer-fill { background: var(--danger); }
.timer-body {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; max-width: 620px; margin: 0 auto;
}
.timer-clock { display: grid; min-width: 96px; }
.timer-clock span {
  font-size: 2rem; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.timer.over .timer-clock span { color: var(--danger); }
.timer-clock small { font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-actions { display: flex; gap: 8px; margin-left: auto; }
.btn-round {
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 0.85rem; font-weight: 700;
  display: grid; place-items: center; flex: none;
}
.btn-round-primary { background: var(--accent); border-color: var(--accent); color: #06210f; }
body.has-timer .nav { display: none; }
body.has-timer { padding-bottom: calc(120px + var(--safe-b)); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(150px + var(--safe-b));
  transform: translateX(-50%);
  background: #262b36; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; z-index: 60;
  font-size: 0.88rem; max-width: 92vw; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ---------- Install-Button ---------- */
.install-btn {
  position: fixed; right: 16px; bottom: calc(96px + var(--safe-b));
  z-index: 70;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px;
  background: var(--accent); border: none; color: #06210f;
  font-size: 0.9rem; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  animation: install-in 0.25s ease;
}
.install-btn svg { flex: none; }
body.has-timer .install-btn { bottom: calc(150px + var(--safe-b)); }
@keyframes install-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Installiert (Standalone/PWA) -> Install-Button niemals anzeigen */
@media all and (display-mode: standalone),
       all and (display-mode: window-controls-overlay),
       all and (display-mode: minimal-ui),
       all and (display-mode: fullscreen) {
  .install-btn { display: none !important; }
}

/* ---------- Login ---------- */
.auth { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.auth-logo { font-size: 2.6rem; text-align: center; margin-bottom: 6px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.8rem; margin: 16px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.err { color: var(--danger); font-size: 0.86rem; }
.ok { color: var(--accent); font-size: 0.86rem; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.empty span { font-size: 2rem; display: block; margin-bottom: 8px; }

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
