/* FORGE – arkusz stylów. Bez kroku budowania: zwykły CSS z tokenami. */

@font-face {
  font-family: "Barlow Condensed";
  src: url("../fonts/barlow-condensed-semibold.woff") format("woff");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("../fonts/barlow-condensed-bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  /* Grafit i kreda – baza */
  --bg: #1a1e23;
  --surface: #23282e;
  --surface-2: #2c323a;
  --line: #3a414a;
  --chalk: #ece8df;
  --muted: #a3acb6;
  --faint: #79828d;
  /* Kolory talerzy olimpijskich – znaczenie, nie dekoracja */
  --plate-yellow: #f2c230;   /* główna akcja */
  --plate-green: #3dbb7d;    /* progresja / zrobione */
  --plate-blue: #5a9bf0;     /* informacja / trening A */
  --plate-red: #ef5a5f;      /* ból / usuwanie */
  --on-yellow: #1a1e23;
  --tpl-a: var(--plate-blue);
  --tpl-b: #e7a23c;

  --font-num: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 20px;
  --tap: 52px;
  --gutter: 16px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--chalk);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
img, video { max-width: 100%; display: block; border-radius: var(--r-md); }
a { color: var(--plate-blue); }
:focus-visible { outline: 3px solid var(--plate-yellow); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Szkielet ───────────────────────────── */
.app { max-width: 560px; margin: 0 auto; padding: 12px var(--gutter) calc(var(--nav-h) + var(--safe-b) + 24px); }
.app--bare { padding-bottom: calc(var(--safe-b) + 24px); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; margin-bottom: 8px; }
.topbar h1, .h1 { font: 700 30px/1.05 var(--font-num); letter-spacing: .01em; margin: 0; }
.back { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); text-decoration: none; font-weight: 600; }
.h2 { font: 700 22px/1.15 var(--font-num); margin: 28px 0 10px; letter-spacing: .01em; }
.h3 { font: 600 18px/1.2 var(--font-num); margin: 0 0 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 14px; }
.small { font-size: 14px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 28px; } .mb { margin-bottom: 16px; }
.prose { max-width: 68ch; white-space: pre-line; }

/* Dolna nawigacja – w zasięgu kciuka */
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav ul { list-style: none; margin: 0 auto; padding: 0; max-width: 560px; display: grid; grid-template-columns: repeat(5, 1fr); }
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--nav-h); color: var(--faint); text-decoration: none; font-size: 12px; font-weight: 600;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--chalk); }
.nav a[aria-current="page"] svg { color: var(--plate-yellow); }

/* ── Przyciski ───────────────────────────── */
.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: var(--r-md);
  font: 600 17px/1 var(--font-body); color: var(--chalk); background: var(--surface-2);
  touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); filter: brightness(.95); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--plate-yellow); color: var(--on-yellow); }
.btn--go { background: var(--plate-green); color: #0f2a1d; }
.btn--danger { background: transparent; color: var(--plate-red); border: 1px solid color-mix(in srgb, var(--plate-red) 55%, transparent); }
.btn--ghost { background: transparent; border: 1px solid var(--line); }
.btn--quiet { background: transparent; color: var(--muted); padding: 0 10px; }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: var(--r-sm); }

/* Główne CTA treningu: najbardziej charakterystyczny element pulpitu */
.start {
  display: block; width: 100%; text-align: left; text-decoration: none;
  background: var(--plate-yellow); color: var(--on-yellow); border-radius: var(--r-lg);
  padding: 22px 22px 20px; margin: 4px 0 8px; border: 0; cursor: pointer;
}
.start__kicker { font: 600 15px/1.2 var(--font-body); opacity: .8; }
.start__label { display: block; font: 700 52px/0.92 var(--font-num); letter-spacing: .005em; margin: 6px 0 10px; }
.start__meta { font: 600 15px/1.3 var(--font-body); }
.start--resume { background: var(--plate-green); color: #0f2a1d; }

/* Talerz – oznaczenie treningu A/B */
.plate {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  font: 700 22px/1 var(--font-num); color: #10151b;
  background: var(--plate-c, var(--muted));
  box-shadow: inset 0 0 0 4px color-mix(in srgb, #000 18%, transparent), inset 0 0 0 9px var(--plate-c, var(--muted)), inset 0 0 0 10px color-mix(in srgb, #000 22%, transparent);
}
.plate--A { --plate-c: var(--tpl-a); }
.plate--B { --plate-c: var(--tpl-b); }
.plate--sm { width: 32px; height: 32px; font-size: 17px; box-shadow: inset 0 0 0 3px color-mix(in srgb, #000 18%, transparent); }

/* ── Listy i panele ─────────────────────── */
.panel { background: var(--surface); border-radius: var(--r-md); padding: 16px; }
.panel--flat { background: transparent; border: 1px solid var(--line); }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list > li { border-bottom: 1px solid var(--line); }
.list__link {
  display: flex; align-items: center; gap: 12px; padding: 14px 2px; min-height: 60px;
  color: inherit; text-decoration: none;
}
.list__title { font-weight: 600; }
.list__sub { color: var(--muted); font-size: 14px; }
.chev { color: var(--faint); flex: none; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge--green { background: color-mix(in srgb, var(--plate-green) 20%, transparent); color: var(--plate-green); }
.badge--red { background: color-mix(in srgb, var(--plate-red) 20%, transparent); color: var(--plate-red); }
.badge--blue { background: color-mix(in srgb, var(--plate-blue) 20%, transparent); color: var(--plate-blue); }
.badge--yellow { background: color-mix(in srgb, var(--plate-yellow) 20%, transparent); color: var(--plate-yellow); }

.note {
  border-left: 3px solid var(--plate-blue); padding: 10px 12px; background: var(--surface);
  border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: 15px;
}
.note--warn { border-color: var(--plate-yellow); }
.note--bad { border-color: var(--plate-red); }
.note--good { border-color: var(--plate-green); }
.flash { margin-bottom: 14px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-radius: var(--r-md); overflow: hidden; }
.stats > div { background: var(--surface); padding: 12px; }
.stats b { display: block; font: 700 30px/1 var(--font-num); }
.stats span { font-size: 13px; color: var(--muted); }

/* ── Formularze ─────────────────────────── */
label, .label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { color: var(--faint); font-size: 13px; margin-top: 4px; }
.error { color: var(--plate-red); font-size: 14px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--surface); color: var(--chalk); border: 1px solid var(--line); font: 17px var(--font-body);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--plate-yellow); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--plate-yellow) 35%, transparent); }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--plate-yellow); }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* Skala 1–5 i przełączniki segmentowe */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  margin: 0; display: grid; place-items: center; min-height: var(--tap); border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); font: 700 22px var(--font-num); cursor: pointer;
}
.seg label small { display: block; font: 500 11px var(--font-body); color: var(--muted); }
.seg input:checked + label { background: var(--chalk); color: var(--bg); border-color: var(--chalk); }
.seg input:checked + label small { color: var(--surface-2); }
.seg input:focus-visible + label { outline: 3px solid var(--plate-yellow); }
.scale-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: 4px; }

/* ── Aktywny trening ─────────────────────── */
.wk-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.wk-head .grow h1 { font: 700 26px/1 var(--font-num); margin: 0; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--plate-green); }
.sync[data-state="pending"]::before { background: var(--plate-yellow); }
.sync[data-state="offline"]::before { background: var(--faint); }
.sync[data-state="error"]::before, .sync[data-state="conflict"]::before { background: var(--plate-red); }

.progress-strip { display: flex; gap: 3px; margin: 10px 0 14px; }
.progress-strip span { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-2); }
.progress-strip span.done { background: var(--plate-green); }
.progress-strip span.cur { background: var(--plate-yellow); }

.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)) 12px; padding: 0 var(--gutter); }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 14px var(--font-body); cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--chalk); color: var(--bg); border-color: var(--chalk); }

.ex-title { font: 700 32px/1 var(--font-num); margin: 2px 0 6px; letter-spacing: .005em; }
.presc { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 15px; margin-bottom: 12px; }
.presc b { color: var(--chalk); font: 700 19px var(--font-num); }

/* Rejestrator serii – jedyny „głośny” element ekranu */
.logger { background: var(--surface); border-radius: var(--r-lg); padding: 14px 14px 16px; }
.logger__set { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.logger__set b { font: 700 20px var(--font-num); }
.dial { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 6px; margin: 4px 0; }
.dial__btn {
  height: 64px; border-radius: var(--r-md); border: 0; background: var(--surface-2); color: var(--chalk);
  font: 700 30px var(--font-num); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.dial__btn:active { background: var(--line); }
.dial__val { text-align: center; }
.dial__val input {
  width: 100%; min-height: 0; padding: 0; border: 0; background: transparent; text-align: center;
  font: 700 64px/1 var(--font-num); color: var(--chalk); font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.dial__val input::-webkit-outer-spin-button, .dial__val input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dial__val input:focus { box-shadow: none; }
.dial__unit { display: block; font-size: 13px; color: var(--muted); margin-top: -2px; }
.dial-sep { text-align: center; font: 600 24px/1 var(--font-num); color: var(--faint); margin: -2px 0; }

.rir { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 12px 0 8px; }
.rir button {
  min-height: 48px; border-radius: var(--r-sm); border: 1px solid var(--line); background: transparent;
  color: var(--chalk); font: 700 22px var(--font-num); cursor: pointer;
}
.rir button[aria-pressed="true"] { background: var(--chalk); color: var(--bg); border-color: var(--chalk); }
.rir button.target { border-color: var(--plate-green); }
.flags { display: flex; gap: 6px; margin-bottom: 12px; }
.flag {
  flex: 1; min-height: 44px; border-radius: var(--r-sm); border: 1px solid var(--line); background: transparent;
  color: var(--muted); font: 600 14px var(--font-body); cursor: pointer; padding: 0 6px;
}
.flag[aria-pressed="true"] { color: var(--bg); background: var(--plate-yellow); border-color: var(--plate-yellow); }
.flag[data-flag="pain"][aria-pressed="true"] { background: var(--plate-red); border-color: var(--plate-red); color: #fff; }

.sets { list-style: none; padding: 0; margin: 14px 0 0; }
.sets li {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center;
  min-height: 52px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.sets li:last-child { border-bottom: 0; }
.sets .n { font: 700 18px var(--font-num); color: var(--faint); }
.sets .v { font: 700 24px var(--font-num); }
.sets .v small { font: 500 14px var(--font-body); color: var(--muted); margin-left: 6px; }
.sets li.warm .v { color: var(--muted); font-size: 20px; }
.sets li.pending .n::after { content: "•"; color: var(--plate-yellow); margin-left: 2px; }

.last { font-size: 14px; color: var(--muted); }
.last b { color: var(--chalk); font-family: var(--font-num); font-size: 17px; }

/* Timer odpoczynku – przyklejony nad nawigacją */
.timer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 10px var(--gutter) calc(10px + var(--safe-b));
  background: var(--surface-2); border-top: 1px solid var(--line);
}
.timer__inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; }
.timer__time { font: 700 40px/1 var(--font-num); min-width: 96px; font-variant-numeric: tabular-nums; }
.timer__bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.timer__bar i { display: block; height: 100%; background: var(--plate-yellow); transform-origin: left; }
.timer--done { background: var(--plate-green); color: #0f2a1d; }
.timer--done .btn { background: rgba(0,0,0,.15); color: inherit; }
.timer-space { height: 180px; }

/* Arkusz (bottom sheet) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 8px var(--gutter) calc(20px + var(--safe-b));
  max-width: 560px; margin: 0 auto; animation: sheet-in .18s ease-out;
}
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 12px; }
@keyframes sheet-in { from { transform: translateY(24px); } to { transform: none; opacity: 1; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top, 0px)); z-index: 60; box-shadow: 0 6px 24px rgba(0,0,0,.4);
  background: var(--chalk); color: var(--bg); padding: 12px 16px; border-radius: var(--r-md); font-weight: 600; max-width: calc(100% - 32px);
}

/* Rutyny (rozgrzewka/mobilizacja) */
.routine li { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 0; }
.routine .done-mark { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: transparent; color: transparent; cursor: pointer; font-size: 22px; }
.routine .done-mark[aria-pressed="true"] { background: var(--plate-green); border-color: var(--plate-green); color: #0f2a1d; }
.routine .skipped .list__title { text-decoration: line-through; color: var(--faint); }

/* Sortowanie listy ćwiczeń */
.order li { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; padding: 8px 0; }

/* ── Wykresy (SVG po stronie serwera) ───── */
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--surface-2); stroke-width: 1; }
.chart .lbl { fill: var(--faint); font: 12px var(--font-body); }
.chart .line { fill: none; stroke: var(--plate-yellow); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .line--2 { stroke: var(--plate-blue); }
.chart .dot { fill: var(--plate-yellow); }
.chart .dot--2 { fill: var(--plate-blue); }
.chart .bar { fill: var(--plate-blue); }
.chart .bar--b { fill: var(--tpl-b); }
.chart .val { fill: var(--chalk); font: 600 12px var(--font-body); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.hbar { display: grid; grid-template-columns: minmax(0, 1fr) 2fr auto; gap: 10px; align-items: center; font-size: 14px; padding: 5px 0; }
.hbar__track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.hbar__fill { height: 100%; background: var(--plate-blue); border-radius: 5px; }
.hbar--arms .hbar__fill { background: var(--plate-yellow); }

table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.data td { padding: 10px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }

details.more > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--muted); font-weight: 600; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "+"; margin-left: auto; font-size: 22px; }
details.more[open] > summary::after { content: "−"; }

.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }
.wordmark { font: 700 64px/0.9 var(--font-num); letter-spacing: .04em; margin: 0 0 4px; }
.wordmark span { color: var(--plate-yellow); }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .btn { margin-top: 12px; }

@media (min-width: 600px) {
  .app { padding-top: 28px; }
}
