:root {
  --bg: #f4f6fb; --card: #ffffff; --text: #1b2433; --muted: #6b7587; --line: #e1e6f0;
  --accent: #2f5fd0; --accent2: #e8833a; --ok: #2e9d62; --danger: #c9372c; --nav: #ffffff;
  --top: #1F3864; --field: var(--bg);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1422; --card: #172033; --text: #e8ecf5; --muted: #93a0b8; --line: #26324a;
    --accent: #6c93ff; --accent2: #ffa05c; --ok: #4cc386; --danger: #ff6b5e; --nav: #131b2d;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding-top: env(safe-area-inset-top, 0px);
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.4rem; margin: .4rem 0 .8rem; }
h2 { font-size: 1.05rem; margin: 1.3rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.more { font-weight: 400; margin-left: .5rem; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; background: var(--top); color: #fff;
}
.top-links { display: flex; gap: .9rem; }
.top-links a { color: #cfd8ee; font-size: .9rem; }
.top-links a.on { color: #fff; font-weight: 700; }
.brand { display: inline-flex; align-items: center; color: #fff; font-weight: 800; letter-spacing: .5px; font-size: 1.25rem; line-height: 1; }
/* logo: biceps z ikony jako litera „o” */
.brand-o { width: 1.05em; height: 1.05em; margin: 0 .04em; transform: translateY(.06em); }
.top .link { background: none; border: 0; color: #cfd8ee; font-size: .9rem; cursor: pointer; }

.wrap { max-width: 640px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.wrap.has-nav { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem; margin-bottom: .9rem;
}
.flash { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .9rem; font-size: .95rem; }
.flash.ok { background: rgba(46,157,98,.15); color: var(--ok); }
.flash.err { background: rgba(201,55,44,.14); color: var(--danger); }
.flash.warn { background: rgba(232,131,58,.16); color: var(--accent2); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .6rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; }
.stat-label { display: block; font-size: .78rem; color: var(--muted); }
.stat-value { display: block; font-size: 1.3rem; font-weight: 700; margin-top: .1rem; }
.stat-sub { display: block; font-size: .78rem; color: var(--muted); }

.chart-box { position: relative; height: 220px; }

.field { display: block; margin-bottom: .8rem; font-size: .88rem; color: var(--muted); }
.field input, .field select, input[type=text], input[type=email], input[type=password], input[type=date], select {
  width: 100%; margin-top: .25rem; padding: .65rem .7rem; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--text);
}
.check { display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem; color: var(--muted); font-size: .9rem; }
.check input { width: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.three { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: .5rem; }
@media (max-width: 440px) {
  .three { grid-template-columns: 1fr 1fr; }
  .three > :first-child { grid-column: 1 / -1; }
}

.btn {
  display: inline-block; padding: .6rem 1rem; font-size: .95rem; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-block { display: block; width: 100%; padding: .8rem; font-size: 1rem; }
.btn-small { padding: .35rem .6rem; font-size: .85rem; }

.pills { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.pill { padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 600; }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.ex { border-top: 1px solid var(--line); padding: .8rem 0; }
.ex-name { font-weight: 700; margin-bottom: .4rem; display: flex; align-items: center; gap: .4rem; }
.ex-name .grow { flex: 1; }
.ex-tools { display: flex; gap: .3rem; }
.ex-del { display: flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--muted); font-weight: 400; }
.ex-del input { width: auto; margin: 0; }
.ex-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; }
.ex-fields label { font-size: .72rem; color: var(--muted); }
.ex-fields input { margin-top: .2rem; padding: .6rem .3rem; text-align: center; }
.ex-fields input::placeholder { color: var(--muted); opacity: .55; }

.list .row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .6rem 0; border-top: 1px solid var(--line); color: var(--text); }
.list .row:first-child { border-top: 0; }
.list form { margin: 0; }
.row-actions { display: flex; gap: .35rem; }
.pr { color: var(--accent2); font-weight: 700; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { margin: 0; }
details.card summary { cursor: pointer; font-weight: 700; }

.timer {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(4.4rem + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem .5rem 1rem;
  background: var(--accent); color: #fff; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.timer-time { font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; min-width: 4.2rem; }
.timer .btn { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }
.timer.done { background: var(--ok); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: .45rem .3rem; border-bottom: 1px solid var(--line); }
.tbl th { font-size: .75rem; color: var(--muted); font-weight: 600; }

.pager { display: flex; justify-content: space-between; gap: .6rem; }

.inline-form { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.inline-form input { margin-top: 0; flex: 1; min-width: 0; }
.inline-form.grow { flex: 1; margin-bottom: 0; }
.ex-list { list-style: none; padding: 0; margin: .4rem 0 .8rem; }
.ex-list li { display: flex; gap: .4rem; align-items: center; margin-bottom: .45rem; }
.ex-list form { margin: 0; }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--nav);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 10;
}
.bottom a { flex: 1; text-align: center; padding: .5rem 0 .45rem; font-size: .68rem; color: var(--muted); }
.bottom a i { display: block; font-style: normal; font-size: 1.3rem; line-height: 1.2; }
.bottom a.on { color: var(--accent); font-weight: 700; }

/* --- otwarty trening, lewa/prawa --- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); vertical-align: middle; }
.tag-live { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.draft-banner { display: flex; align-items: center; justify-content: space-between; gap: .6rem; color: var(--text); border-color: var(--accent2); }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.plan-list { margin-bottom: .6rem; }
.plan-item { padding: .55rem 0; margin: 0; border-top: 1px solid var(--line); color: var(--text); font-size: 1rem; }
.plan-item input { width: 1.2rem; height: 1.2rem; }

.card.ex { border-top: 1px solid var(--line); padding: .8rem .9rem; }
.card.ex.saved { border-left: 4px solid var(--ok); }
.ex-ok { display: none; color: var(--ok); }
.ex.saved .ex-ok { display: inline; }
.ex-row { padding: .25rem 0; }
.ex-row.has-side { display: grid; grid-template-columns: 2.4rem 1fr; gap: .4rem; align-items: end; }
.side { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 2.6rem; border-radius: 10px; font-weight: 800; font-size: 1.05rem; color: #fff; line-height: 1; }
.side small { font-size: .55rem; font-weight: 600; opacity: .85; margin-top: .1rem; }
.side-L { background: var(--accent); }
.side-R { background: var(--accent2); }
.side-inline { display: inline-block; min-width: 1.2rem; text-align: center; font-size: .7rem; font-weight: 800; color: #fff; border-radius: 5px; padding: 0 .25rem; margin-right: .15rem; }
.ex-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .5rem; }
.side-toggle { display: flex; align-items: center; gap: .2rem; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.side-toggle input { width: auto; margin: 0; }
.stat-wide { grid-column: 1 / -1; }

/* --- konto, motywy, administracja, cardio --- */
.card-title { margin: 0 0 .7rem; }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .5rem; }
.theme-opt { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .5rem; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; font-size: .85rem; }
.theme-opt input { display: none; }
.theme-opt:has(input:checked) { border-color: var(--accent); font-weight: 700; }
.theme-swatch { display: flex; width: 100%; height: 46px; border-radius: 8px; overflow: hidden; background-size: cover; background-position: center; }
.theme-swatch i { flex: 1; }
.theme-swatch-classic { background: linear-gradient(135deg, #f4f6fb 50%, #0e1422 50%); }
.theme-swatch-classic i:nth-child(2) { background: #2f5fd0; flex: .35; margin: 14px 0; border-radius: 4px; }
.theme-swatch-graphite { background: #16181d; }
.theme-swatch-graphite i:nth-child(2) { background: #ff5a36; flex: .35; margin: 14px 0; border-radius: 4px; }
.theme-swatch-gym { background-image: url('/img/gym-bg.jpg'); }
.theme-swatch-gym i:nth-child(2) { background: #ff8a3d; flex: .35; margin: 14px 0; border-radius: 4px; }

.temp-pass { border-color: var(--accent2); }
.temp-row { display: flex; align-items: center; gap: .6rem; margin: .3rem 0; }
.temp-row code { font-size: 1.4rem; font-weight: 800; letter-spacing: .08em; padding: .3rem .6rem; border-radius: 8px; background: var(--field); user-select: all; }
.user-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.user-head form { margin: 0; }
.user-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .8rem; margin-top: .6rem; font-size: .82rem; color: var(--muted); }
.user-stats b { color: var(--text); }

.pills-radio .pill { cursor: pointer; }
.pills-radio .pill input { display: none; }
.pills-radio .pill:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
a.stat-link { color: var(--text); }

/* --- motyw: Grafit --- */
:root[data-theme="graphite"] {
  --bg: #0f1013; --card: #1a1c21; --text: #eceef2; --muted: #9298a4; --line: #2a2d34;
  --accent: #ff5a36; --accent2: #ffc145; --ok: #3ddc97; --danger: #ff5d73; --nav: #15171b;
  --top: #16181d; --field: #111216;
}

/* --- motyw: Siłownia (rozmyte zdjęcie sali w tle, „szklane” karty) --- */
:root[data-theme="gym"] {
  --bg: #0d0a09; --card: rgba(22, 17, 15, .72); --text: #f3ece6; --muted: #b7a99f; --line: rgba(255, 255, 255, .12);
  --accent: #ff8a3d; --accent2: #ffd166; --ok: #5ee39a; --danger: #ff6b5e; --nav: rgba(14, 10, 9, .82);
  --top: rgba(12, 9, 8, .72); --field: rgba(0, 0, 0, .35);
}
:root[data-theme="gym"] body { background: var(--bg); }
:root[data-theme="gym"] body::before {
  /* zdjęcie (domyślne lub własne) przychodzi w --bg-image, rozmycie w --bg-blur; ujemny inset chowa rozmyte krawędzie */
  content: ''; position: fixed; inset: -40px; z-index: -1;
  background: var(--bg-image, url('/img/gym-bg.jpg')) center / cover no-repeat;
  filter: blur(var(--bg-blur, 3px)) brightness(.62);
}
:root[data-theme="gym"] .card, :root[data-theme="gym"] .stat, :root[data-theme="gym"] .bottom, :root[data-theme="gym"] .top, :root[data-theme="gym"] .pill {
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
:root[data-theme="gym"] .pill { background: rgba(22, 17, 15, .6); }
:root[data-theme="gym"] .top { position: sticky; top: 0; z-index: 9; }

/* --- wersja, historia zmian, wybór pliku --- */
.version { margin-top: 1.6rem; text-align: center; font-size: .72rem; color: var(--muted); opacity: .75; }
.version a { color: inherit; text-decoration: underline; }
.changelog h1 { margin-top: 0; }
.changelog h2 { margin: 1.2rem 0 .3rem; font-size: 1rem; }
.changelog ul { margin: .2rem 0; padding-left: 1.2rem; }
.changelog li { margin: .2rem 0; }
.changelog p { color: var(--muted); font-size: .88rem; }
.file-btn { text-align: center; cursor: pointer; margin-bottom: .4rem; }
