/* Anmutung nach Apple Fitness und Whoop:
   echtes Schwarz, kaum Linien, große Zahlen, Ringe, wenige satte Farben.

   Bewusst nur Dunkelmodus — beide Referenzen sind reine Dunkel-Apps, und der
   schwarze Grund ist der Grund, warum satte Farben und dünne Zahlen tragen. */

:root {
  /* Flächen: echtes Schwarz als Grund, Stufen darüber statt Rahmen */
  --bg: #000000;
  --s1: #101012;
  --s2: #1c1c1f;
  --s3: #2a2a2e;

  --text: #ffffff;
  --text-2: #98989f;
  --text-3: #6c6c72;

  /* Akzent für Aktionen und Erledigtes */
  --accent: #30d158;
  --accent-dim: rgba(48, 209, 88, 0.16);

  /* Die drei Bewegungsfamilien — Ringfarben, wie die Aktivitätsringe */
  --push: #ff375f;
  --pull: #30d158;
  --legs: #0ac8ff;

  --pr: #ffd60a;
  --danger: #ff453a;

  /* Abstandsskala — vorher war das zusammengewürfelt */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --tap: 44px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; overscroll-behavior-y: none; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, input, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  -webkit-appearance: none;
  appearance: none;
}
button { cursor: pointer; user-select: none; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Typografie ────────────────────────────────────────────────────────
   Zahlen sind das Thema: groß, dünn, eng, immer tabellarisch. Labels sind
   klein, gesperrt, in Großbuchstaben. Dazwischen fast nichts. */

.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  font-weight: 300;
}
.num-lg { font-size: 34px; line-height: 1; }
.num-xl { font-size: 56px; line-height: 1; }

.cap {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ── Rahmen ────────────────────────────────────────────────────────── */

#app { display: flex; flex-direction: column; min-height: 100%; max-width: 560px; margin: 0 auto; }

#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 54px;
  padding: calc(env(safe-area-inset-top) + 8px) var(--sp-3) var(--sp-2);
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
}

#title {
  flex: 1;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#topActions { display: flex; gap: 0; }

.icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  color: var(--text);
}
.icon-btn:active { background: var(--s2); }

#screen { flex: 1; padding: var(--sp-3) var(--sp-4) calc(env(safe-area-inset-bottom) + 92px); }

#tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--sp-2) 0 6px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.tab svg { width: 25px; height: 25px; }
.tab.active { color: var(--accent); }
#tabbar [data-tab="more"] svg circle { fill: currentColor; stroke: none; }
#app:has(#tabbar[hidden]) #screen { padding-bottom: calc(env(safe-area-inset-bottom) + var(--sp-5)); }

/* ── Karten und Zeilen ─────────────────────────────────────────────────
   Keine Rahmen. Die Karte ist eine Flächenstufe, Zeilen trennt Abstand. */

.card { background: var(--s1); border-radius: var(--r-md); overflow: hidden; }
.card + .card { margin-top: var(--sp-2); }

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 60px;
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
}
.row + .row { box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.06); }
.row:active { background: var(--s2); }
.row-main { flex: 1; min-width: 0; display: block; }
.row-title {
  display: block;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-sub { display: block; font-size: 13px; color: var(--text-2); margin-top: 2px; }
.row-chev { color: var(--text-3); flex: none; }
.row-chev svg { width: 17px; height: 17px; stroke-width: 2.4; }
.row-val { flex: none; font-size: 20px; color: var(--text); }

.section-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: var(--sp-5) var(--sp-1) var(--sp-2);
}
.section-label:first-child { margin-top: var(--sp-2); }

.hint { font-size: 13px; line-height: 1.55; color: var(--text-3); margin: var(--sp-2) var(--sp-1) 0; }

.empty { padding: var(--sp-7) var(--sp-5); text-align: center; color: var(--text-3); font-size: 15px; line-height: 1.6; }

/* ── Knöpfe ────────────────────────────────────────────────────────── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 50px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-sm);
  background: var(--s2);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.btn:active { background: var(--s3); transform: scale(0.98); }
.btn.primary { background: var(--accent); color: #04180a; }
.btn.primary:active { background: #28b94c; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; color: var(--text-2); }
.btn.ghost:active { background: var(--s1); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 var(--sp-4);
  border-radius: 999px;
  background: var(--s2);
  font-size: 15px;
  white-space: nowrap;
}
.pill:active { background: var(--accent); color: #04180a; }
.pill svg { width: 15px; height: 15px; flex: none; stroke-width: 2.6; }

.stepper { display: flex; align-items: center; flex: none; background: var(--s2); border-radius: var(--r-sm); }
.stepper button { width: 38px; height: 38px; display: grid; place-items: center; font-size: 20px; color: var(--text-2); }
.stepper button:active { color: var(--text); }
.stepper span {
  min-width: 26px;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

input[type="text"], input[type="number"], input[type="search"] {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--s2);
  font-size: 17px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
input::placeholder { color: var(--text-3); }

/* ── Ringe ─────────────────────────────────────────────────────────────
   Das Signaturelement. Drei Bewegungsfamilien, wie die Aktivitätsringe. */

.rings { display: flex; justify-content: space-around; gap: var(--sp-3); padding: var(--sp-5) var(--sp-4) var(--sp-4); }
.ring { text-align: center; flex: 1; }
.ring svg { width: 76px; height: 76px; stroke: none; fill: none; display: block; margin: 0 auto; }
.ring circle { fill: none; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }
.ring .track { stroke: var(--s2); }
.ring-num {
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  fill: var(--text);
  stroke: none;
}
.ring-lbl { margin-top: 6px; font-size: 11px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); }

/* ── Builder ───────────────────────────────────────────────────────── */

.meta-bar { display: flex; gap: var(--sp-5); padding: 0 var(--sp-1) var(--sp-4); }
.meta-item { display: block; }
.meta-num { display: block; font-size: 26px; font-weight: 300; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.meta-lbl { display: block; font-size: 11px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); margin-top: 3px; }

.ex-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); background: var(--s1); }
.ex-row + .ex-row { box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.06); }
.ex-row.dragging { opacity: 0.35; background: var(--s2); }

.ex-fam { flex: none; width: 3px; align-self: stretch; border-radius: 2px; min-height: 38px; }
.ex-fam.push { background: var(--push); }
.ex-fam.pull { background: var(--pull); }
.ex-fam.legs { background: var(--legs); }

.ex-main { flex: 1; min-width: 0; }
.ex-cap { display: block; font-size: 10px; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-3); }
.ex-name {
  display: block;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ex-target { flex: none; text-align: right; }
.ex-target-val { display: block; font-size: 24px; font-weight: 300; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; }
.ex-target-val i { font-style: normal; color: var(--text-3); font-size: 16px; margin: 0 1px; }
.ex-target-val u { text-decoration: none; color: var(--text-2); font-size: 14px; }
.ex-rest { display: block; font-size: 11px; color: var(--text-3); margin-top: 4px; letter-spacing: 0.02em; white-space: nowrap; }

.grip { flex: none; width: 28px; height: 40px; display: grid; place-items: center; color: var(--text-3); touch-action: none; }
.grip svg { width: 17px; height: 17px; }

.search-wrap {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + 68px);
  z-index: 10;
  margin: var(--sp-5) calc(-1 * var(--sp-4)) 0;
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  background: linear-gradient(to top, #000 42%, rgba(0, 0, 0, 0.88));
  backdrop-filter: blur(20px);
}
.sug-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.sug-hint { font-size: 11px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); margin-top: var(--sp-3); }

/* ── Gym-Modus ─────────────────────────────────────────────────────── */

.gym-head { padding: 0 var(--sp-1) var(--sp-4); }
.gym-prog { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.gym-ex-name { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-top: 6px; }
.gym-ex-sub { font-size: 14px; color: var(--text-2); margin-top: var(--sp-2); }
.gym-ex-sub b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

/* Kopfzeile einmal statt Label über jeder Satzzeile */
.set-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4) 2px; }
.set-head .set-field {
  text-align: center;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}

.set-row { display: flex; align-items: center; gap: var(--sp-3); padding: 6px var(--sp-4); }
.set-row.done { background: var(--accent-dim); }
.set-no {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--s2);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.set-row.done .set-no { background: var(--accent); color: #04180a; }
/* Felder mittig und begrenzt statt über die ganze Breite gestreckt — bei
   Körpergewichtsübungen gibt es nur eines, sonst klafft die Zeile. */
.set-fields { flex: 1; display: flex; justify-content: center; gap: var(--sp-3); min-width: 0; }
.set-field { flex: 0 1 104px; min-width: 0; }
.set-field input {
  min-height: 44px;
  padding: 0 var(--sp-1);
  text-align: center;
  font-size: 21px;
  font-weight: 300;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  background: var(--s2);
  border-radius: var(--r-sm);
}
.set-row.done .set-field input { background: transparent; }
.set-row.done .set-field input { color: var(--text); }
.set-field input::placeholder { color: var(--text-3); font-weight: 300; }

.check-btn {
  flex: none;
  width: 46px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--text-3);
}
/* Ungehakt ist ein leerer Rahmen, nicht eine gefüllte Fläche — sonst sieht
   der Knopf aus, als wäre er schon gedrückt. */
.check-btn span {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--s3);
  display: grid;
  place-items: center;
}
.check-btn svg { opacity: 0; }
.set-row.done .check-btn { color: #04180a; }
.set-row.done .check-btn span { background: var(--accent); border-color: var(--accent); }
.set-row.done .check-btn svg { opacity: 1; }
.check-btn svg { width: 17px; height: 17px; stroke-width: 3; }

@keyframes pop { 40% { transform: scale(1.28); } }
.set-row.just-done .check-btn span { animation: pop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1); }

.gym-nav { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); }
.gym-nav .btn { flex: 1; padding: 0 var(--sp-3); }

.up-next .row { min-height: 54px; }
.up-next .row.done .row-title { color: var(--text-3); }

/* ── Pausentimer als Ring ──────────────────────────────────────────── */

#rest { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--bg); }
#restInner { text-align: center; padding: var(--sp-5); }
#restRing { position: relative; width: 268px; height: 268px; margin: 0 auto var(--sp-6); }
#restRing svg { width: 268px; height: 268px; stroke: none; fill: none; }
#restRing circle { fill: none; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }
#restRing .track { stroke: var(--s1); }
#restRing .prog { stroke: var(--accent); transition: stroke-dashoffset 0.98s linear; }
#restRing.over .prog { stroke: var(--pr); }

#restCenter { position: absolute; inset: 0; display: grid; place-content: center; gap: var(--sp-2); }
#restLabel { font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
#restTime { font-size: 62px; font-weight: 200; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1; }
#restRing.over #restTime { color: var(--pr); }
#restNext { font-size: 13px; color: var(--text-2); }

#restBtns { display: flex; gap: var(--sp-3); justify-content: center; }
#restBtns button { min-width: 104px; min-height: 50px; border-radius: var(--r-sm); background: var(--s2); font-size: 16px; font-weight: 500; }
#restBtns button:active { background: var(--s3); }
#restSkip { margin-top: var(--sp-4); min-height: 50px; padding: 0 var(--sp-6); border-radius: var(--r-sm); color: var(--accent); font-size: 16px; font-weight: 500; }

/* ── Abschluss-Übersicht ───────────────────────────────────────────── */

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.summary-tile { background: var(--s1); border-radius: var(--r-md); padding: var(--sp-4); }
.summary-num { font-size: 32px; font-weight: 300; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.summary-lbl { font-size: 11px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); margin-top: 6px; }

/* ── Sheet ─────────────────────────────────────────────────────────── */

#sheet { position: fixed; inset: 0; z-index: 50; }
#sheetBackdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
#sheetBody {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88%;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-4) calc(env(safe-area-inset-bottom) + var(--sp-5));
  background: var(--s1);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  animation: rise 0.26s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes rise { from { transform: translateY(100%); } }
#sheetBody .card { background: var(--s2); }
/* Im Sheet liegt die Karte auf s2 — die Ringspur braucht eine Stufe mehr. */
#sheetBody .ring .track { stroke: var(--s3); }
#sheetBody .btn { background: var(--s2); }
#sheetBody .btn.primary { background: var(--accent); }
#sheetBody .btn.ghost { background: none; }
.sheet-title { font-size: 24px; font-weight: 700; letter-spacing: -0.025em; margin-bottom: var(--sp-4); }
.sheet-text { font-size: 15px; line-height: 1.55; color: var(--text-2); margin-bottom: var(--sp-4); }
.sheet-stack { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ── Toast ─────────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 100px);
  transform: translateX(-50%);
  z-index: 70;
  max-width: 88%;
  padding: var(--sp-3) var(--sp-5);
  border-radius: 999px;
  background: var(--s3);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
