:root {
  --bg: #0f1115;
  --card: #181b22;
  --card2: #20242d;
  --line: #2a2f3a;
  --text: #eceef2;
  --muted: #8b93a3;
  --accent: #4ade80;
  --accent-ink: #062b14;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(24px + var(--safe-b));
}
body.has-nav { padding-bottom: calc(84px + var(--safe-b)); }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h2 { font-size: 26px; margin: 4px 0 10px; }
h3 { font-size: 17px; }
h3 a { display: block; }
h4.section, h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(15, 17, 21, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { padding: 12px 12px 0; max-width: 640px; margin: 0 auto; }

.card {
  display: block; background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; border: 1px solid var(--line);
}
a.card:active { background: var(--card2); }
.card.hero h2 { margin-top: 2px; }
.card.item { padding: 12px 14px; margin-bottom: 8px; }
.section { display: block; margin: 16px 4px 8px; }
div.section, .row.section { margin: 16px 4px 8px; }

.row { display: flex; gap: 8px; align-items: center; }
.row > input, .row > select { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.gap-top { margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.big { font-size: 24px; font-weight: 700; margin: 6px 0 10px; }
.big .small { font-weight: 400; }
ul.plain { list-style: none; padding: 0; margin: 0 0 14px; }
ul.plain li { padding: 3px 0; }

input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 4px; }
.check-label { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 15px; }
.check-label input { width: 22px; min-height: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 15px; color: var(--text);
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; min-height: 44px; cursor: pointer; white-space: nowrap;
}
.btn:active { filter: brightness(1.2); }
.btn:disabled { opacity: .35; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn.icon { min-width: 40px; padding: 8px; }
.link { background: none; border: 0; padding: 6px 0; font: inherit; font-size: 15px; color: var(--accent); cursor: pointer; }
.link.danger { color: var(--danger); }
.default-submit { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.pill { font-size: 12.5px; padding: 3px 9px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.pill.live { color: var(--accent); background: rgba(74, 222, 128, .12); }
.flash { background: rgba(74, 222, 128, .12); color: var(--accent); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.error { color: var(--danger); }
strong.text { color: var(--text); }
.login { margin-top: 20vh; }

details.more summary { color: var(--muted); font-size: 14px; padding: 12px 0 2px; cursor: pointer; }
details.more[open] summary { margin-bottom: 8px; }

/* Ekran treningu */
.workout-head { padding: 10px 14px; }
.exercise { scroll-margin-top: 70px; }
.exercise.complete { border-color: rgba(74, 222, 128, .45); }
.exercise h3 { padding-right: 8px; }
.last { margin-top: 6px; color: var(--text); }
.hint { font-size: 13px; margin-top: 6px; padding: 5px 9px; border-radius: 8px; display: inline-block; }
.hint.up { background: rgba(74, 222, 128, .14); color: var(--accent); }
.hint.keep { background: rgba(96, 165, 250, .12); color: var(--info); }
.hint.down { background: rgba(251, 191, 36, .14); color: var(--warn); }
.hint.new { background: var(--card2); color: var(--muted); }

.sets { margin-top: 10px; }
.set { display: grid; grid-template-columns: 28px 1fr 1fr 52px; gap: 8px; align-items: center; margin-bottom: 6px; }
.set.cardio { grid-template-columns: 24px 1fr 1fr 1fr 48px; gap: 6px; }
.set.cardio input { font-size: 17px; }
.set.head { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.set .no { text-align: center; color: var(--muted); font-weight: 600; }
.set input { text-align: center; font-size: 18px; font-weight: 600; padding: 8px 4px; }
.set .check {
  height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2);
  color: var(--muted); font-size: 20px; font-weight: 700; cursor: pointer;
}
.set.done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.set.done input { background: rgba(74, 222, 128, .08); border-color: rgba(74, 222, 128, .3); }
.set.saving .check { opacity: .5; }
.set.invalid input { border-color: var(--danger); }
.add-set { font-size: 14px; }

details.menu { position: relative; }
details.menu summary { list-style: none; cursor: pointer; font-size: 22px; line-height: 1; padding: 2px 8px 8px; color: var(--muted); }
details.menu summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: 34px; z-index: 5; width: min(320px, 82vw);
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); display: grid; gap: 8px;
}
.menu-body .btn { background: var(--card); }

.rest {
  position: sticky; top: calc(52px + var(--safe-t)); z-index: 9;
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  background: var(--info); color: #06162b; border-radius: 12px; padding: 8px 10px 8px 14px;
}
.rest[hidden] { display: none; }
.rest strong { font-size: 22px; font-variant-numeric: tabular-nums; margin-right: auto; margin-left: 4px; }
.rest button { background: rgba(0, 0, 0, .15); border: 0; color: inherit; font: inherit; font-weight: 700; border-radius: 8px; min-width: 44px; min-height: 36px; }
.rest.over { background: var(--accent); color: var(--accent-ink); animation: pulse .6s ease-in-out 3; }
@keyframes pulse { 50% { transform: scale(1.02); } }

/* Waga i statystyki */
.weight-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats3 strong { font-size: 17px; display: block; }
.chart { position: relative; height: 220px; margin-top: 14px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14.5px; margin-top: 8px; }
table.list td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
table.list td a { color: var(--accent); }
table.list .num { text-align: right; white-space: nowrap; }
table.list form { display: inline; }
.muscles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.muscles div { background: var(--card2); border-radius: 8px; padding: 6px 8px; display: flex; justify-content: space-between; font-size: 13px; }
.muscles div.zero { opacity: .45; }
.muscles strong { color: var(--accent); }
.zero strong { color: var(--muted); }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg a { padding: 5px 10px; font-size: 13px; border-radius: 7px; color: var(--muted); }
.seg a.on { background: var(--card2); color: var(--text); }

/* Ustawienia */
.menu-list { padding: 0; }
.menu-list a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 13px 14px; border-top: 1px solid var(--line); }
.menu-list a:first-child { border-top: 0; }
.menu-list a > span:last-child { color: var(--muted); }
.tpl-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.tpl-row:first-of-type { border-top: 0; }
.tpl-row > a { flex: 1; min-width: 0; }
.tpl-row.off > a { opacity: .5; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.grid4 label { margin: 0; font-size: 12px; }
.grid4 input { text-align: center; padding: 8px 4px; }

/* Dolna nawigacja */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(24, 27, 34, .96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; color: var(--muted); }
.tabs a svg { width: 24px; height: 24px; }
.tabs a.on { color: var(--accent); }
