:root {
  --bg: #0d0d0f;
  --surface: #17171b;
  --surface-2: #202028;
  --text: #f2f2f5;
  --muted: #8a8a94;
  --accent: #ff6a2b;
  --border: #2a2a33;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
}

.screen[hidden] { display: none; }

.screen {
  padding: 24px 20px;
  animation: fade 0.15s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.screen-head { margin-bottom: 16px; }

h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }

.muted { color: var(--muted); }
.placeholder { margin-top: 8px; font-size: 16px; }

/* Ekran powitalny */
.welcome {
  min-height: calc(100vh - var(--tabbar-h) - var(--safe-b) - 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}
.welcome-logo { font-size: 64px; }
.welcome h1 { font-size: 40px; }

/* Dolna nawigacja */
#tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
#tabbar[hidden] { display: none; }

.tab {
  flex: 1;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab[aria-selected="true"] { color: var(--accent); }

.tab-ico { font-size: 22px; line-height: 1; }
.tab-lbl { font-size: 11px; font-weight: 600; }

/* --- Karty i listy --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 16px;
  margin-bottom: 20px;
}
.day-name { font-size: 20px; font-weight: 700; margin: 4px 0 12px; }

.ex-list, .ex-row { list-style: none; }
.ex-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.ex-row:first-child { border-top: none; }
.ex-name { font-size: 16px; font-weight: 600; }
.ex-scheme { font-size: 14px; color: var(--muted); white-space: nowrap; }

/* --- Duze przyciski --- */
.btn-save {
  display: block;
  width: 100%;
  min-height: 64px;
  border: none;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-save:active { filter: brightness(0.9); }

.btn-line {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* --- Ekran treningu --- */
.wk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.wk-cancel {
  min-height: 44px;
  padding: 0 4px;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.wk-progress { font-size: 15px; font-weight: 700; color: var(--accent); }
.wk-name { font-size: 26px; margin-bottom: 4px; }
.wk-target { font-size: 14px; margin-bottom: 20px; }
.wk-last { margin-top: 18px; font-size: 13px; text-align: center; }

.wk-fail {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 15px;
}
.wk-fail-box { width: 22px; height: 22px; accent-color: var(--accent); }

/* --- Steppery --- */
.stepper {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 16px;
}
.step-btn {
  flex: 0 0 72px;
  min-height: 72px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 34px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.step-btn:active { background: var(--surface); }
.step-val {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.step-num { font-size: 34px; font-weight: 800; line-height: 1; }
.step-unit { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* --- Suwak RPE --- */
.rpe { margin-bottom: 20px; }
.rpe-lbl { display: block; font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.rpe-val { color: var(--accent); font-weight: 800; }
.rpe-range {
  width: 100%;
  height: 44px;
  accent-color: var(--accent);
  background: transparent;
}

/* --- Timer przerwy (pelnoekranowy) --- */
#rest-timer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
}
#rest-timer[hidden] { display: none; }
.rest-title { font-size: 20px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.rest-count { font-size: 96px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rest-skip {
  min-height: 64px;
  padding: 0 48px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

/* --- Historia --- */
.sess {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
}
.sess summary {
  padding: 14px 16px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sess summary::-webkit-details-marker { display: none; }
.sess-date { font-size: 16px; font-weight: 700; }
.sess-meta { font-size: 13px; color: var(--muted); }
.sess-sets { list-style: none; padding: 0 16px 14px; }
.sess-sets li { font-size: 14px; padding: 4px 0; border-top: 1px solid var(--border); }

/* --- Karty dni (ekran Dzis) --- */
.day-cards { display: flex; flex-direction: column; gap: 12px; }
.day-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.day-card:active { background: var(--surface-2); }
.day-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.day-card-name { font-size: 18px; font-weight: 700; }
.focus-tag {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
}
.focus-tag[data-focus="SQUAT"]    { background: #7a3e12; color: #ffd9bf; }
.focus-tag[data-focus="BENCH"]    { background: #123a6b; color: #cfe3ff; }
.focus-tag[data-focus="DEADLIFT"] { background: #6b1220; color: #ffd0d6; }
.focus-tag[data-focus="RUN"]      { background: #123f2a; color: #c6f5da; }
.day-card-ex { list-style: none; padding: 0; margin: 0 0 10px; }
.day-card-ex li { font-size: 14px; color: var(--muted); padding: 2px 0; }
.day-card-last { font-size: 12px; color: var(--muted); }

/* --- Warianty na ekranie treningu --- */
.variant-btn {
  min-width: 44px;
  min-height: 44px;
  vertical-align: middle;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
}
.variant-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.variant-panel[hidden] { display: none; }
.variant-opt {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.variant-opt.current { border-color: var(--accent); color: var(--accent); font-weight: 700; }

.wk-end { margin-top: 12px; }

/* --- Wpis biegowy --- */
.run-lbl { display: block; font-size: 15px; font-weight: 600; margin: 12px 0 6px; }
.num-input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
}
.run-lbl + .num-input { margin-bottom: 8px; }
#run-min { margin-bottom: 20px; }

/* --- Toast --- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  transform: translateX(-50%);
  z-index: 200;
  max-width: 90%;
  padding: 12px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
#toast[hidden] { display: none; }
