/* =========================================================
   style.css – Aussehen der Trainings-App
   Hell mit dunklen Akzenten · Salbeigrün #7d9e7d · Manrope
   Mobile-first, Tap-Targets >= 48px
   ========================================================= */
:root {
  --sage: #7d9e7d;
  --sage-dark: #5f7d5f;
  --sage-soft: #e9efe7;
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1f2421;
  --muted: #6b7280;
  --line: #e6e8e2;
  --danger: #b45454;
  --ok: #7d9e7d;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(31, 36, 33, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 620px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

a { color: var(--sage-dark); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(246, 247, 245, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .tb-title { font-weight: 800; font-size: 1.05rem; }
.topbar a, .topbar button.linklike {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 12px;
  text-decoration: none; color: var(--text);
  font-weight: 600; border-radius: 12px; background: transparent;
  border: none; cursor: pointer; font-size: 0.95rem;
}
.topbar a:active { background: var(--sage-soft); }

/* ---------- Überschriften ---------- */
h1 { font-size: 1.5rem; font-weight: 800; margin: 8px 0 4px; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.sub { color: var(--muted); font-size: 0.92rem; margin: 0 0 16px; }

/* ---------- Karten / Listen ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 0 10px;
}
.section-head h2 { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.85rem; color: var(--sage-dark); }

/* Übungszeile */
.ex {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.ex.dragging { opacity: 0.6; }
.ex .grip {
  cursor: grab; touch-action: none; user-select: none;
  color: var(--muted); font-size: 1.2rem;
  min-width: 28px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.ex .ex-body { flex: 1; min-width: 0; }
.ex .ex-name { font-weight: 700; }
.ex .ex-meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  background: var(--sage-soft); color: var(--sage-dark);
  padding: 2px 8px; border-radius: 999px; margin-left: 6px;
}
.ex.hidden-ex { opacity: 0.6; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  font-family: inherit; font-size: 1rem; font-weight: 700;
  border-radius: 14px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; width: auto;
}
.btn-primary { background: var(--sage); color: #fff; }
.btn-primary:active { background: var(--sage-dark); }
.btn-ghost { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.1rem; }
.btn-icon {
  min-width: 44px; min-height: 44px; padding: 0;
  border-radius: 12px; background: var(--sage-soft); color: var(--sage-dark);
  border: none; font-size: 1.3rem; font-weight: 800; cursor: pointer;
}
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- ··· Menü ---------- */
.menu-wrap { position: relative; }
.menu-btn {
  min-width: 44px; min-height: 44px; border: none; background: transparent;
  font-size: 1.4rem; color: var(--muted); cursor: pointer; border-radius: 12px;
}
.menu-btn:active { background: var(--sage-soft); }
.menu {
  display: none; position: absolute; right: 0; top: 48px; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12); overflow: hidden; min-width: 170px;
}
.menu.open { display: block; }
.menu button, .menu .menu-item {
  display: block; width: 100%; text-align: left;
  padding: 14px 16px; min-height: 48px;
  background: #fff; border: none; border-bottom: 1px solid var(--line);
  font-family: inherit; font-size: 0.98rem; color: var(--text); cursor: pointer;
}
.menu button:last-child, .menu .menu-item:last-child { border-bottom: none; }
.menu button:active { background: var(--sage-soft); }
.menu .danger { color: var(--danger); }

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(31,36,33,0.45); align-items: flex-end; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; width: 100%; max-width: 620px;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
}
.modal h2 { margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.field input[type=text], .field input[type=number], .field select {
  width: 100%; min-height: 48px; padding: 0 14px;
  font-family: inherit; font-size: 16px; /* 16px = kein Auto-Zoom auf iOS */
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text);
}
.field.checkbox { display: flex; align-items: center; gap: 10px; }
.field.checkbox input { width: 22px; height: 22px; }
.field.checkbox label { margin: 0; }

/* ---------- Login ---------- */
.login-wrap { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.pin-input {
  width: 100%; min-height: 60px; text-align: center; letter-spacing: 0.4em;
  font-size: 1.6rem; font-weight: 700;
  border: 1px solid var(--line); border-radius: 14px; background: #fff;
}
.error-box {
  background: #fbeaea; color: var(--danger); border: 1px solid #f0caca;
  padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600;
}

/* ---------- Userauswahl ---------- */
.user-grid { display: grid; gap: 14px; }
.user-card {
  display: flex; align-items: center; gap: 14px;
  padding: 20px; text-decoration: none; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-height: 76px;
}
.user-card:active { background: var(--sage-soft); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--sage); color: #fff; font-weight: 800; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
}
.user-card .name { font-weight: 800; font-size: 1.15rem; }

/* ---------- Aktive Übung ---------- */
.progress {
  height: 8px; background: var(--sage-soft); border-radius: 999px; overflow: hidden; margin: 4px 0 16px;
}
.progress > span { display: block; height: 100%; background: var(--sage); transition: width 0.3s ease; }
.ex-kicker { color: var(--sage-dark); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; font-weight: 800; }
.ex-title { font-size: 1.7rem; font-weight: 800; margin: 2px 0 6px; overflow-wrap: break-word; }
.ref { color: var(--muted); font-size: 0.95rem; margin-bottom: 14px; overflow-wrap: break-word; }
.ref strong { color: var(--text); }

/* Bild der Übung – ganze Illustration sichtbar (kein Beschnitt) */
.ex-photo {
  position: relative;
  height: 210px; border-radius: 14px; background: var(--sage-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--sage-dark); font-weight: 700; margin-bottom: 14px; overflow: hidden;
}
.ex-photo img { width: 100%; height: 100%; object-fit: contain; }
.ex-photo.has-img { cursor: zoom-in; }
.zoom-hint {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(31,36,33,0.62); color: #fff;
  font-size: 0.72rem; font-weight: 600; padding: 4px 8px; border-radius: 999px;
  pointer-events: none;
}

/* Vollbild-Zoom (Lightbox) */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(31,36,33,0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; cursor: zoom-out;
  opacity: 0; transition: opacity .2s ease;
}
.lightbox.open { opacity: 1; }
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: 12px; background: #fff;
}

/* Ein Satz: stapelt sich bei wenig Platz, nie seitliches Scrollen */
.set {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff;
}
.set.done { background: var(--sage-soft); border-color: var(--sage); }
.set-check { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.set-check input { width: 26px; height: 26px; accent-color: var(--sage); }
/* Kopfzeile eines Satzes: Haken links, Zusammenfassung + Aufklapp-Pfeil rechts */
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.set-summary {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 0.95rem; font-weight: 700; color: var(--muted);
  padding: 6px 2px; min-height: 44px;
}
.set-sum-text .sw, .set-sum-text .sr { color: var(--text); }
.set-chevron { font-size: 1.1rem; transition: transform .2s ease; }
.set.open .set-chevron { transform: rotate(180deg); }
/* kg + Wdh: am Handy untereinander (volle Breite fürs Gewicht),
   ab 480px nebeneinander. Nie seitliches Scrollen. */
.set-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 480px) {
  .set-controls { grid-template-columns: 1fr 1fr; }
}
/* eingeklappt: Felder wirklich ausblenden (schlägt display:grid) */
.set-controls[hidden] { display: none; }
.ctl {
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0;                 /* erlaubt Schrumpfen -> kein Überlauf */
}
.ctl .lbl {
  color: var(--muted); font-size: 0.76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}
/* +/- Knöpfe nebeneinander OBERHALB der Anzeige */
.ctl-btns {
  display: flex; gap: 8px;
  min-width: 0;
}
.step {
  flex: 1 1 0; min-width: 0; height: 48px;
  border-radius: 12px; border: none;
  background: var(--sage-soft); color: var(--sage-dark);
  font-size: 1.4rem; font-weight: 800; line-height: 1; cursor: pointer;
}
.step:active { background: var(--sage); color: #fff; }
.num {
  flex: 1 1 auto; min-width: 0; width: 100%; height: 48px;
  text-align: center; padding: 0 6px;
  font-size: 1.15rem; font-weight: 700; font-family: inherit;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text);
  -moz-appearance: textfield;
}
/* native Spinner ausblenden – wir haben eigene +/- Knöpfe */
.num::-webkit-outer-spin-button,
.num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.note-input {
  width: 100%; min-height: 48px; padding: 0 14px;
  font-family: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text);
}
.note-line { color: var(--sage-dark); font-size: 0.88rem; margin-top: 4px; }

/* feste Navigation am unteren Rand der Übung */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(246,247,245,0.95); border-top: 1px solid var(--line); backdrop-filter: blur(8px);
}
.bottom-nav .btn { flex: 1; }
.bottom-nav-spacer { height: 88px; }

/* ---------- Zusammenfassung / Historie ---------- */
.big-stat { display: flex; gap: 20px; margin: 8px 0 18px; }
.big-stat .stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; flex: 1; box-shadow: var(--shadow); }
.big-stat .stat .v { font-size: 1.5rem; font-weight: 800; }
.big-stat .stat .l { color: var(--muted); font-size: 0.8rem; }
.sum-ex { padding: 10px 0; border-bottom: 1px solid var(--line); }
.sum-ex:last-child { border-bottom: none; }
.sum-ex .nm { font-weight: 700; }
.sum-sets { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.tick { color: var(--ok); font-weight: 800; }

.hist-item { display: flex; justify-content: space-between; gap: 12px; }
.hist-item .d { font-weight: 700; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
