:root {
  --bg: #0c1613;
  --surface: #122421;
  --surface-2: #1a332e;
  --border: #294843;
  --text: #eef4f1;
  --text-dim: #9ab0aa;
  --accent: #f2911e;
  --accent-ink: #20140a;
  --accent-2: #4f8089;
  --accent-3: #8a6fd1;
  --accent-4: #5fa86e;
  --danger: #d9694a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

body {
  padding-bottom: 32px;
}

a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  letter-spacing: .01em;
}

.topbar .back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: .9rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:active { background: var(--surface-2); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 48px 16px;
  font-size: .95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
}
.tile .info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}
.tile .info:active { opacity: .8; }
.tile .tile-name {
  font-weight: 600;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tile .tile-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tile .tile-sub {
  font-size: .72rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile .delete-btn {
  color: var(--text-dim);
  background: none;
  border: none;
  font-size: 1.1rem;
  padding: 6px;
  cursor: pointer;
}

/* Filtr rodzaju treningu nad listą na home - te same kolory co .type-badge
   (statystyki/daty treningu), ale klikalne i z wyraźnym stanem aktywnym,
   żeby łatwo odnaleźć wcześniej skonfigurowany trening danego rodzaju. */
.type-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.type-filter-btn {
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 7px 13px;
  border-radius: 100px;
  white-space: nowrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
}
.type-filter-btn.active.all { background: var(--surface-2); color: var(--text); border-color: var(--text-dim); }
.type-filter-btn.active.strength { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent); border-color: var(--accent); }
.type-filter-btn.active.treadmill { background: color-mix(in srgb, var(--accent-2) 18%, var(--surface)); color: var(--accent-2); border-color: var(--accent-2); }
.type-filter-btn.active.stairs { background: color-mix(in srgb, var(--accent-3) 18%, var(--surface)); color: var(--accent-3); border-color: var(--accent-3); }
.type-filter-btn.active.other { background: color-mix(in srgb, var(--accent-4) 18%, var(--surface)); color: var(--accent-4); border-color: var(--accent-4); }

#exercise-list, #template-list, #stage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exercise-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
}
.exercise-row .info { flex: 1; min-width: 0; }
.exercise-row .name {
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exercise-row .sets-summary {
  font-size: .72rem;
  color: var(--text-dim);
  margin-top: 3px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exercise-row .progress-bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.exercise-row .progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .2s ease;
}
.exercise-row .progress-label {
  font-size: .72rem;
  color: var(--text-dim);
  margin-top: 4px;
}
.exercise-row .delete-btn {
  color: var(--text-dim);
  background: none;
  border: none;
  font-size: 1.1rem;
  padding: 6px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 100px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; }

input[type="text"], input[type="number"], input[type="password"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: .95rem;
  width: 100%;
  min-height: 64px;
  resize: vertical;
  font-family: inherit;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.field-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.modal-backdrop[hidden] { display: none; }
.modal-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.scheme-toggle {
  display: flex;
  gap: 8px;
}
.scheme-option {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 12px;
  padding: 10px 8px;
  font-size: .88rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  line-height: 1.5;
}
.scheme-option small {
  font-weight: 400;
  font-size: .74rem;
  color: inherit;
  opacity: .85;
}
.scheme-option.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions .btn { flex: 1; }

.sets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.set-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.set-col .set-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-dim);
}
.set-col .kg-input {
  width: 100%;
  text-align: center;
  padding: 8px 4px;
}
.set-col .kg-unit {
  font-size: .68rem;
  color: var(--text-dim);
  margin-top: -6px;
}
.rep-pills {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  align-items: center;
}
.rep-pill {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.rep-pill.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.timer-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
}
.timer-overlay[hidden] { display: none; }
.timer-overlay.minimized {
  inset: auto;
  bottom: 16px;
  right: 16px;
  left: 16px;
  top: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  padding: 10px 18px;
  gap: 10px;
}
.timer-label {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .08em;
  font-size: 1.1rem;
}
.timer-ring-wrap {
  position: relative;
  width: min(70vw, 260px);
  height: min(70vw, 260px);
}
.timer-overlay.minimized .timer-ring-wrap {
  width: auto;
  height: auto;
}
.timer-ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-overlay.minimized .timer-ring-wrap svg { display: none; }
.timer-ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.timer-ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .2s linear; }
.timer-time {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.timer-overlay.minimized .timer-time {
  position: static;
  font-size: 1.1rem;
  font-weight: 700;
}
.timer-controls {
  display: flex;
  gap: 12px;
}
.timer-overlay.minimized .timer-controls {
  gap: 10px;
  margin-left: auto;
}
.timer-icon-btn {
  width: 64px;
  height: 64px;
  border: none;
  background: none;
  padding: 0;
  font-size: 2.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.timer-icon-btn:active { transform: scale(.9); }
.timer-overlay.minimized .timer-icon-btn { width: 44px; height: 44px; font-size: 1.5rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: .92rem;
  z-index: 40;
}

.finish-btn-wrap { padding-top: 8px; }

.stage-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Odhaczanie etapu na ekranie bieżni - wyłącznie wizualne (nic nie zapisuje),
   ma pomóc skupić się na kolejnym nadchodzącym etapie w trakcie biegu. */
.stage-check-btn {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: transparent;
  font-size: .95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.stage-check-btn.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.stage-row.done {
  opacity: .5;
}

/* Schody: etykieta etapu + lista wejść (plan modułu Schody) - gap między wierszami
   już ustawiony wyżej (#exercise-list, #template-list, #stage-list { gap: 10px }),
   dodatkowy margin-top na etykiecie etapu robi wyraźniejszy odstęp między grupami. */
.stage-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 4px 12px;
  margin-top: 18px;
  border-bottom: 1px dashed var(--border);
}
.stage-label-row:first-child { margin-top: 0; }
.stage-label-row .stage-name {
  font-weight: 700;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.stage-actions .delete-btn {
  color: var(--text-dim);
  background: none;
  border: none;
  font-size: 1rem;
  padding: 6px;
  cursor: pointer;
}
.stage-plus {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--accent-3);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 6px;
  flex-shrink: 0;
}
.stage-plus:active { opacity: .8; }

.climb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.climb-row .climb-name {
  font-weight: 600;
  font-size: .92rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text);
}
.play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.play-btn:disabled { opacity: .3; cursor: default; }
.climb-time {
  border: none;
  background: none;
  color: var(--accent-2);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 6px 4px;
  cursor: pointer;
  min-width: 52px;
  text-align: right;
}
.climb-time.running { color: var(--accent); }
.climb-time:disabled { opacity: .3; cursor: default; }

.globals-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Statystyki: ekran "Daty treningu" (plan, sekcja 13) - płaska lista zakończonych
   treningów z podziałkami miesięcznymi, bez nawigacji dalej (czysto informacyjna). */
#date-list {
  display: flex;
  flex-direction: column;
}
.month-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 4px 8px;
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--accent-2);
}
.month-divider:first-child { padding-top: 4px; }
.month-divider .cnt {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
}
.date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.date-row .dr-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.date-row .dr-when {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .78rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.date-row .dr-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.type-badge {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  flex-shrink: 0;
}
.type-badge.strength { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.type-badge.treadmill { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 45%, var(--border)); }
.type-badge.stairs { color: var(--accent-3); border-color: color-mix(in srgb, var(--accent-3) 45%, var(--border)); }
.type-badge.other { color: var(--accent-4); border-color: color-mix(in srgb, var(--accent-4) 45%, var(--border)); }

/* Inne: duża notatka zamiast listy ćwiczeń + wyświetlanie notatki w szczegółach sesji. */
.other-note { min-height: 260px; }
.detail-note { white-space: pre-wrap; word-break: break-word; font-size: .95rem; line-height: 1.5; }
/* Wybór typu w modalu dodawania: 4 opcje łamią się do siatki 2x2 zamiast ściskać się w jednym rzędzie. */
#new-template-type { flex-wrap: wrap; }
#new-template-type .scheme-option { flex: 1 1 calc(50% - 4px); }

/* Statystyki: wiersz "Daty treningu" jest teraz klikalny - otwiera szczegóły sesji. */
.date-row.clickable {
  cursor: pointer;
}
.date-row.clickable:active {
  opacity: .8;
}

/* Statystyki: szczegóły pojedynczej sesji (session.html) - read-only widok tego, co
   zostało zrobione w danym treningu (ćwiczenia+ciężary / etapy bieżni / wejścia
   schodowe), żeby porównać stary trening z aktualnym (plan, sekcja 13). */
.session-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 4px 18px;
}
.session-meta .dr-when {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .82rem;
  color: var(--text-dim);
}
.detail-group-title {
  font-weight: 700;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  padding: 18px 4px 8px;
}
.detail-group-title:first-child { padding-top: 4px; }
.detail-block {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}
.detail-block-title {
  font-weight: 600;
  font-size: 1rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .85rem;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
}
