:root {
  --bg: #f3f5f8; --card: #ffffff; --ink: #1b2430; --muted: #5d6b7d; --line: #d9e0e8;
  --brand: #1f3a5f; --brand-ink: #ffffff; --accent: #2f6fbd;
  --star: #fff6d6; --ss: #e3f4f4; --input: #fffdf0;
  --ok: #2e7d32; --okbg: #dff0d8; --warn: #a65b00; --warnbg: #fde9d0; --bad: #b3261e; --badbg: #f9dcd9; --infobg: #e3ecf8;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151d; --card: #18212c; --ink: #e8edf3; --muted: #9aa8b8; --line: #2b3745;
    --brand: #27456f; --accent: #6ea8ee;
    --star: #3a3320; --ss: #17323a; --input: #222c38;
    --ok: #7bd17f; --okbg: #1f3a22; --warn: #f0b36a; --warnbg: #46331a; --bad: #f2928b; --badbg: #4a2320; --infobg: #1f3047;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px 24px; }
h1 { font-size: 1.25rem; margin: 4px 0 12px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: .88rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hero { background: var(--brand); color: var(--brand-ink); border: 0; }
.hero .muted { color: #c6d4e6; }
.hero b { font-size: 1.15rem; }

/* przyciski i pola */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 10px 14px; border-radius: 10px; min-height: 44px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--bad); }
button.small { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
button.block { width: 100%; }
button:disabled { opacity: .5; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--input); border: 1px solid var(--line); border-radius: 8px; padding: 9px 8px; min-height: 44px; width: 100%; }
input[type=number], input.n { text-align: center; }
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
.field { flex: 1; min-width: 70px; }
.sets { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 8px; margin: 8px 0; }

/* nawigacja */
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.nav a { flex: 1; text-align: center; padding: 8px 0 7px; text-decoration: none; color: var(--muted); font-size: .72rem; }
.nav a span { display: block; font-size: 1.35rem; line-height: 1.2; }
.nav a.on { color: var(--accent); font-weight: 600; }

/* ćwiczenia */
.ex { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; overflow: hidden; }
.ex.star { background: var(--star); }
.ex.ss { border-left: 5px solid #38a3a5; }
.ex-head { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; border: 0; background: transparent; border-radius: 0; padding: 12px; min-height: 56px; }
.ex-head .id { font-weight: 700; min-width: 38px; color: var(--accent); }
.ex-head .nm { flex: 1; font-weight: 600; line-height: 1.25; }
.ex-head .meta { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.ex-head .chk { width: 22px; text-align: center; color: var(--ok); font-weight: 700; }
.ex-body { padding: 0 12px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: var(--infobg); border-radius: 999px; padding: 3px 10px; font-size: .82rem; }
.tech { font-size: .92rem; margin: 8px 0; }
.gal { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.gal figure { margin: 0; position: relative; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 4 / 3; }
.gal img { width: 100%; height: 100%; object-fit: contain; display: block; cursor: zoom-in; }
.gal figcaption { position: absolute; left: 6px; top: 6px; background: rgba(31,58,95,.85); color: #fff; font-size: .72rem; padding: 1px 7px; border-radius: 6px; }
.gal figure.missing img { display: none; }
.gal figure.missing::after { content: "brak zdjęcia"; position: absolute; inset: 0; display: grid; place-items: center; color: #8a96a5; font-size: .8rem; }
.last { background: var(--infobg); border-radius: 8px; padding: 6px 10px; font-size: .88rem; margin: 6px 0; }
.rec { margin-top: 8px; padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: .92rem; }
.rec.up { background: var(--okbg); color: var(--ok); }
.rec.keep { background: var(--infobg); }
.rec.down { background: var(--badbg); color: var(--bad); }
.rec.warn { background: var(--warnbg); color: var(--warn); }
.rec.info { background: var(--infobg); }
.idx { font-size: .85rem; color: var(--muted); margin-top: 4px; }

/* listy */
.item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.item:last-child { border-bottom: 0; }
.badge { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: .78rem; font-weight: 700; }
.badge.ok { background: var(--okbg); color: var(--ok); }
.badge.mid { background: var(--warnbg); color: var(--warn); }
.badge.bad { background: var(--badbg); color: var(--bad); }
.badge.off { background: var(--infobg); color: var(--muted); }
.banner { background: var(--warnbg); color: var(--warn); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; font-weight: 600; }
.pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.pills button { white-space: nowrap; }
.pills button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.spark { width: 120px; height: 28px; flex: none; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.spark circle { fill: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.n, th.n { text-align: right; }
details { border-bottom: 1px solid var(--line); padding: 6px 0; }
details summary { cursor: pointer; font-weight: 600; padding: 8px 0; min-height: 40px; }
.cur { outline: 2px solid var(--accent); }

/* stoper i podgląd zdjęć */
.timer { position: fixed; left: 12px; right: 12px; bottom: calc(66px + env(safe-area-inset-bottom)); max-width: 696px; margin: 0 auto; background: var(--brand); color: #fff; border-radius: 14px; padding: 10px 12px; z-index: 11; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.timer .t { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 76px; }
.timer button { background: rgba(255,255,255,.15); color: #fff; border-color: transparent; min-height: 38px; padding: 4px 10px; }
.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 9; border-radius: 999px; background: var(--brand); color: #fff; border: 0; min-height: 48px; padding: 0 18px; box-shadow: 0 3px 10px rgba(0,0,0,.3); font-weight: 600; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 30; display: grid; place-items: center; padding: 12px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 8px; }
[hidden] { display: none !important; }
