:root {
  --bg: #0f1012;
  --surface: #17191c;
  --surface-2: #202328;
  --line: #2a2e34;
  --text: #f1f2f4;
  --muted: #9a9fa8;
  --faint: #6b7079;
  --accent: #ff7a45;
  --accent-ink: #1a0d06;
  --accent-soft: rgba(255, 122, 69, .14);
  --good: #45c08a;
  --good-soft: rgba(69, 192, 138, .14);
  --bad: #ee6468;
  --bad-soft: rgba(238, 100, 104, .14);
  --radius: 16px;
  --tabs-h: 64px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f3f1;
    --surface: #ffffff;
    --surface-2: #eeeeeb;
    --line: #e0e0dc;
    --text: #15171a;
    --muted: #666b73;
    --faint: #93979e;
    --accent: #e8622a;
    --accent-ink: #fff;
    --accent-soft: rgba(232, 98, 42, .12);
    --good: #1d9a5f;
    --good-soft: rgba(29, 154, 95, .12);
    --bad: #d2434a;
    --bad-soft: rgba(210, 67, 74, .1);
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px);
}
body.focus #app { padding-bottom: calc(env(safe-area-inset-bottom) + 150px); }

/* ---------- nagłówki ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { font-size: 30px; line-height: 1.1; margin: 2px 0 0; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 28px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- tydzień ---------- */
.week { display: flex; align-items: center; gap: 8px; }
.week-nav { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; font-size: 22px; color: var(--muted); }
.week-nav:disabled { opacity: .3; }
.week-mid { flex: 1; text-align: center; }
.week-title { font-size: 17px; font-weight: 650; }
.week-dates { font-size: 13px; color: var(--muted); }
.phase { margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--surface); font-size: 14px; color: var(--muted); }
.phase b { color: var(--text); font-weight: 650; }
.phase.deload { background: var(--accent-soft); }
.segs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0 0; }
.segs i { height: 6px; border-radius: 3px; background: var(--surface-2); }
.segs i.on { background: var(--good); }
.segs i.half { background: var(--accent); }
.segs i.skip { background: var(--line); opacity: .5; }

/* ---------- karta głównego treningu ---------- */
.hero {
  margin-top: 18px; padding: 20px; border-radius: 20px; background: var(--surface);
  border: 1px solid var(--line);
}
.hero-day { font-size: 13px; color: var(--muted); }
.hero-name { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 4px; }
.hero-focus { font-size: 14px; color: var(--muted); }
.hero-day.warn { color: var(--accent); font-weight: 600; }
.hero-hint { margin: -6px 0 16px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; color: var(--muted); }
.hero-meta { display: flex; gap: 14px; margin: 14px 0 18px; font-size: 14px; color: var(--muted); }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 54px; border-radius: 14px; font-weight: 650; font-size: 17px;
  background: var(--accent); color: var(--accent-ink);
}
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.line { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: transparent; color: var(--bad); min-height: 44px; font-size: 15px; font-weight: 500; }
.btn + .btn { margin-top: 10px; }
.done-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--good); font-weight: 600; font-size: 15px; }

/* ---------- lista treningów tygodnia ---------- */
.list { border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; text-align: left; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.dot { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.dot.on { background: var(--good); border-color: var(--good); color: #fff; }
.dot.half { border-color: var(--accent); }
.dot svg { width: 15px; height: 15px; }
.dot.skip { border-style: dashed; color: var(--faint); font-weight: 700; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { font-size: 13px; color: var(--muted); }
.chev { color: var(--faint); font-size: 20px; }

textarea.note {
  width: 100%; min-height: 84px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); resize: vertical; font-size: 16px;
}
textarea.note:focus, .field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- widok treningu ---------- */
.wo-head {
  position: sticky; top: 0; z-index: 5; margin: calc(-14px - env(safe-area-inset-top)) -16px 14px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 12px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.wo-bar { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.wo-title { flex: 1; min-width: 0; }
.wo-title b { display: block; font-size: 17px; }
.wo-title span { font-size: 13px; color: var(--muted); }
.wo-clock { font-size: 17px; font-weight: 600; color: var(--muted); }
.prog { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.ex { background: var(--surface); border-radius: var(--radius); margin-bottom: 10px; border: 1px solid transparent; }
.ex.open { border-color: var(--line); }
.ex-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; text-align: left; }
.ex-num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); font-size: 13px; font-weight: 650; display: grid; place-items: center; color: var(--muted); }
.ex.complete .ex-num { background: var(--good); color: #fff; }
.ex-name { flex: 1; min-width: 0; font-weight: 600; }
.ex-scheme { font-size: 14px; color: var(--muted); white-space: nowrap; }
.ex-sum { display: block; font-size: 13px; font-weight: 400; color: var(--muted); margin-top: 1px; }
.ex-body { padding: 0 16px 16px; }
.ex-note { font-size: 14px; color: var(--muted); margin: -4px 0 10px; }
.last { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.last b { color: var(--text); font-weight: 600; }
.cue { display: inline-block; padding: 7px 11px; border-radius: 10px; font-size: 14px; font-weight: 600; background: var(--surface-2); margin-bottom: 14px; }
.cue.up { background: var(--good-soft); color: var(--good); }
.cue.deload, .cue.new { background: var(--accent-soft); color: var(--accent); }
.cue.stall { background: var(--bad-soft); color: var(--bad); }

.set-labels, .set { display: grid; grid-template-columns: 18px 1.15fr 1fr 50px; gap: 6px; align-items: center; }
.set-labels { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.set-labels span { text-align: center; }
.set { margin-bottom: 8px; }
.set-n { font-size: 14px; font-weight: 650; color: var(--muted); text-align: center; }
.stepper { display: flex; align-items: stretch; height: 52px; border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.stepper button { width: 30px; flex: none; font-size: 22px; color: var(--muted); }
.stepper button:active { background: var(--line); }
.stepper input {
  flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; text-align: center;
  font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; padding: 0; letter-spacing: -.02em;
}
.stepper input:focus { outline: none; background: var(--line); }
.stepper input::placeholder { color: var(--faint); font-weight: 500; }
.check { height: 52px; border-radius: 12px; border: 2px solid var(--line); display: grid; place-items: center; color: var(--faint); }
.check svg { width: 24px; height: 24px; }
.set.done .check { background: var(--good); border-color: var(--good); color: #fff; }
.set.done .stepper { background: var(--good-soft); }
.variant { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.variant input { flex: 1; min-width: 0; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: transparent; padding: 0 10px; font-size: 16px; }

/* ---------- timer przerwy ---------- */
.timer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 12px); background: var(--surface);
  border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0, 0, 0, .25);
}
.timer-bar { height: 4px; margin: 0 -16px 12px; background: var(--surface-2); }
.timer-bar i { display: block; height: 100%; background: var(--accent); width: 0; }
.timer-row { display: flex; align-items: center; gap: 8px; max-width: 528px; margin: 0 auto; }
.timer-info { flex: 1; min-width: 0; }
.timer-label { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-time { font-size: 40px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tbtn { height: 48px; min-width: 52px; padding: 0 10px; border-radius: 12px; background: var(--surface-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.tbtn-main { min-width: 76px; }
.timer.ring { background: var(--accent); color: var(--accent-ink); animation: pulse 1s ease-in-out infinite; }
.timer.ring .timer-label { color: inherit; opacity: .8; }
.timer.ring .tbtn { background: rgba(0, 0, 0, .14); }
@keyframes pulse { 50% { filter: brightness(1.12); } }

/* ---------- progres ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 14px; }
.stat b { display: block; font-size: 24px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.grid8 { display: grid; grid-template-columns: 74px repeat(8, 1fr); gap: 5px; align-items: center; background: var(--surface); border-radius: var(--radius); padding: 14px; }
.grid8 .gl { font-size: 12px; color: var(--muted); white-space: nowrap; }
.grid8 .gh { font-size: 11px; color: var(--faint); text-align: center; }
.grid8 .gc { aspect-ratio: 1; border-radius: 6px; background: var(--surface-2); }
.grid8 .gc.on { background: var(--good); }
.grid8 .gc.half { background: var(--accent); }
.grid8 .gc.skip { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.grid8 .gc.now { box-shadow: inset 0 0 0 2px var(--faint); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface); }
.seg button { height: 36px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); }
.pex { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; text-align: left; border-top: 1px solid var(--line); }
.pex:first-child { border-top: 0; }
.pex-main { flex: 1; min-width: 0; }
.pex-name { font-weight: 600; font-size: 15px; }
.pex-sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.spark { flex: none; width: 70px; height: 28px; }
.delta { flex: none; min-width: 64px; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 15px; color: var(--faint); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.pdetail { padding: 4px 16px 16px; border-top: 1px dashed var(--line); }
.chart { width: 100%; height: 140px; display: block; margin: 8px 0 6px; }
.wk-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.wk-table td { padding: 7px 0; border-top: 1px solid var(--line); }
.wk-table td:first-child { color: var(--muted); width: 64px; }
.wk-table td:last-child { text-align: right; color: var(--muted); }
.up-t { color: var(--good); }
.down-t { color: var(--bad); }

/* ---------- zasady ---------- */
details { background: var(--surface); border-radius: var(--radius); margin-bottom: 8px; }
summary { list-style: none; padding: 16px; font-weight: 600; display: flex; justify-content: space-between; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 20px; line-height: 1; }
details[open] summary::after { content: "-"; }
.rules { padding: 0 16px 14px; }
.rules dt { font-weight: 600; font-size: 15px; margin-top: 12px; }
.rules dt:first-child { margin-top: 0; }
.rules dd { margin: 3px 0 0; color: var(--muted); font-size: 15px; }

/* ---------- trener / ustawienia ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; }
.card p { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; }
.field input[type=date], .field input[type=text] { border: 1px solid var(--line); border-radius: 10px; background: transparent; height: 40px; padding: 0 10px; font-size: 16px; max-width: 60%; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.switch i { position: absolute; inset: 0; border-radius: 15px; background: var(--surface-2); transition: background .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ---------- dolne menu ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--faint); }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--accent); }
body.focus .tabs { display: none; }

/* ---------- arkusz (podsumowanie) i toast ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: 100%; max-width: 560px; background: var(--bg); border-radius: 22px 22px 0 0; padding: 24px 16px calc(env(safe-area-inset-bottom) + 18px); max-height: 88vh; overflow: auto; }
.sheet-box h2 { font-size: 26px; margin-bottom: 4px; }
.pr { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 15px; }
.pr span:last-child { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%); z-index: 40; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; font-weight: 600; max-width: calc(100% - 32px); }
