/* Coach — mobile-first. Kolory jako tokeny; tryb ciemny wg ustawień systemu. */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #eeeee9;
  --text: #17181a;
  --muted: #5f6368;
  --border: #dcdcd5;
  --accent: #d9480f;
  --accent-text: #ffffff;
  --danger: #c92a2a;
  --danger-bg: #fff0f0;
  --ok: #2b8a3e;
  --radius: 14px;
  --tap: 48px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #1b1c1f;
    --surface-2: #26282c;
    --text: #ececea;
    --muted: #a0a4aa;
    --border: #33363b;
    --accent: #ff7a3d;
    --accent-text: #141414;
    --danger: #ff8787;
    --danger-bg: #3a1d1d;
    --ok: #69db7c;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.stack > * + * { margin-top: 12px; }

.center {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--accent);
  box-shadow: inset 0 0 0 5px color-mix(in srgb, var(--accent) 60%, #000);
}

label { display: block; font-weight: 600; font-size: .95rem; }

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
}
button.primary, .button.primary {
  width: 100%;
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.alert {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--danger);
  background: var(--danger-bg);
}

.list { list-style: none; margin: 0; padding: 0; }
.list > li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
code.copy {
  display: block; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); word-break: break-all; user-select: all;
}

fieldset { margin: 0; min-width: 0; }
legend { font-weight: 700; padding: 0 4px; }
.card.stack > legend + * { margin-top: 0; }
.field > * + * { margin-top: 6px; }
.label { display: block; font-weight: 600; font-size: .95rem; }
.hint { color: var(--muted); font-size: .875rem; }
.field-error { color: var(--danger); font-size: .9rem; font-weight: 600; }
[aria-invalid="true"] { border-color: var(--danger); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-2 > * + * { margin-top: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap); padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-weight: 600; cursor: pointer;
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }

.switch { display: flex; align-items: center; gap: 12px; min-height: var(--tap); font-weight: 500; }
.switch input { width: 24px; min-height: 24px; height: 24px; accent-color: var(--accent); flex: none; }

/* Układ aplikacji: górny pasek + dolna nawigacja (kciuk). */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.icon-button {
  width: var(--tap); padding: 0; background: transparent; border-color: transparent; color: var(--muted);
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; max-width: 120px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 52px; padding-top: 6px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--accent); }
.page > .card { max-width: none; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: .85rem; }
.scroll-x { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.chip-link {
  flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem;
}
.chip-link[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.row-link {
  display: flex; flex-direction: column; gap: 2px; width: 100%; min-height: var(--tap);
  justify-content: center; color: var(--text); text-decoration: none;
}
.list > li:has(> .row-link) { padding: 6px 0; }
.badge { font-size: .7rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.technique { margin: 0; padding-left: 1.3em; }
.technique li + li { margin-top: 6px; }

h3 { font-size: 1rem; margin: 0; }
.prompt {
  margin: 0; padding: 12px; max-height: 220px; overflow: auto; border-radius: 10px;
  background: var(--surface-2); font-size: .8rem; white-space: pre-wrap; word-break: break-word;
}
textarea { font-family: ui-monospace, monospace; font-size: .85rem; }
input[type="file"] { padding: 10px; }
.big-stats { font-size: 1.05rem; }
.warnings { margin: 0; padding-left: 1.2em; }
.ok { color: var(--ok); font-weight: 600; }
.notice { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 15%, transparent); }
.matches > li { display: block; }
.row-3 { display: grid; grid-template-columns: 1fr; gap: 8px; }
.plan-list { list-style: none; margin: 0; padding: 0; }
.plan-list > li { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.plan-list > li:last-child { border-bottom: 0; }
[hidden] { display: none !important; }
details.card > summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
details.card[open] > summary { margin-bottom: 8px; }
.plan-list a { color: var(--text); font-weight: 600; text-decoration: none; }
.plan-list a:hover { text-decoration: underline; }

/* Animacja ćwiczenia: dwie klatki nałożone, druga miga co 1 s (ADR-008). */
.anim { margin: 0; }
.anim-frames { position: relative; aspect-ratio: 3 / 2; border-radius: var(--radius); overflow: hidden; background: #fff; }
.anim-frames img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.anim-frames img + img { animation: anim-flip 2s steps(1) infinite; }
@keyframes anim-flip { 0% { opacity: 0; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .anim-frames img + img { animation: none; opacity: 0; } }
.anim-small .anim-frames { max-width: 160px; border-radius: 10px; }
.anim figcaption { margin-top: 4px; }

.hero h2 { font-size: 1.4rem; }
.day-choice button { width: 100%; justify-content: flex-start; }
details > summary { cursor: pointer; color: var(--muted); min-height: 32px; }

/* Ekran treningu */
.ex-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ex-head h2 a { color: var(--text); text-decoration: none; }
.is-done { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.ok-badge { color: var(--ok); }
.plan-line { font-weight: 600; }
.sets { list-style: none; margin: 0; padding: 0; }
.set-row { border-top: 1px solid var(--border); }
.set-row summary { min-height: 40px; display: flex; align-items: center; gap: 6px; color: var(--text); font-weight: 600; }
.set-no { color: var(--muted); width: 1.6em; }
.is-warmup summary { color: var(--muted); font-weight: 500; }
.row-edit { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; padding: 6px 0; }
.danger-link { background: none; border: 0; color: var(--danger); padding: 0; min-height: 36px; }
.new-set { display: grid; gap: 10px; }
.new-set label { font-weight: 600; font-size: .9rem; }
.new-set label input { margin-top: 4px; font-size: 1.15rem; text-align: center; }
.rir { border: 0; padding: 0; display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.rir legend { grid-column: 1 / -1; font-weight: 600; font-size: .9rem; margin-bottom: 4px; padding: 0; }
.rir-chip { position: relative; }
.rir-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rir-chip span {
  display: flex; align-items: center; justify-content: center; min-height: var(--tap);
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-weight: 700; font-size: .9rem;
}
.rir-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.rir-chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.technique-box > summary { color: var(--accent); font-weight: 600; }
.rest-timer {
  position: fixed; left: 8px; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 11;
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 14px;
  background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.rest-timer span { flex: 1; font-size: 1.05rem; }
.rest-timer strong { font-variant-numeric: tabular-nums; font-size: 1.3rem; }
.rest-timer button { min-height: 40px; padding: 0 12px; background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
.rest-timer.is-over { background: var(--accent); color: var(--accent-text); }
.row-button { width: 100%; flex-direction: column; align-items: flex-start; background: transparent; border: 0; padding: 8px 0; text-align: left; }
form.card > label, form.card .row-2 > label { font-weight: 600; font-size: .9rem; }
form.card label > input, form.card label > textarea { margin-top: 4px; }
