/* ==========================================================================
   styles.css — mobile first, ciemny motyw, duże pola dotykowe
   ========================================================================== */

:root {
  --bg: #0e1116;
  --bg-2: #161b23;
  --bg-3: #1e252f;
  --line: #2a3341;
  --txt: #e8edf4;
  --txt-2: #9aa7b8;
  --txt-3: #6b7787;
  --acc: #f4a261;
  --ok: #58c98a;
  --warn: #e9c46a;
  --bad: #ef6b6b;
  --rad: 16px;
  --tap: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px; line-height: 1.45;
  overscroll-behavior-y: contain;
}
body { min-height: 100dvh; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input[type=number] { -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* --- ekrany --------------------------------------------------------------*/
.screen { display: none; padding-bottom: calc(24px + var(--safe-b)); }
.screen.is-active { display: block; }

/* --- topbar --------------------------------------------------------------*/
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 12px 10px;
  background: rgba(14, 17, 22, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { display: block; font-size: 12px; font-weight: 500; color: var(--txt-2); }
.icon-btn {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 12px; background: var(--bg-2); color: var(--txt);
  font-size: 18px; border: 1px solid var(--line);
}
.icon-btn:active { background: var(--bg-3); }

.wrap { padding: 16px 14px 0; max-width: 720px; margin: 0 auto; }

/* --- ekran startowy ------------------------------------------------------*/
.hero { padding: 22px 14px 6px; max-width: 720px; margin: 0 auto; }
.hero h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--txt-2); font-size: 14px; }

.card-list { display: grid; gap: 12px; }
.wcard {
  display: block; width: 100%; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line);
  border-left: 4px solid var(--acc);
  border-radius: var(--rad); padding: 14px 14px 12px;
}
.wcard:active { background: var(--bg-3); }
.wcard .row1 { display: flex; align-items: baseline; gap: 8px; }
.wcard .ico { font-size: 20px; }
.wcard h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; flex: 1; }
.wcard .goal { margin: 6px 0 0; font-size: 13px; color: var(--txt-2); }
.wcard .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  padding: 4px 9px; border-radius: 999px;
  background: var(--bg-3); color: var(--txt-2); border: 1px solid var(--line);
}
.chip.acc { background: color-mix(in srgb, var(--acc) 16%, transparent); color: var(--acc); border-color: transparent; }
.chip.ok  { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); border-color: transparent; }

.sec-title {
  margin: 26px 0 10px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--txt-3);
}

/* --- timeline ------------------------------------------------------------*/
.timeline {
  position: sticky; top: calc(58px + var(--safe-t)); z-index: 20;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.timeline::-webkit-scrollbar { display: none; }
.tl-item {
  flex: 0 0 auto; min-width: 44px; max-width: 132px;
  padding: 7px 10px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-size: 11.5px; color: var(--txt-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-item .n { font-weight: 700; color: var(--txt-3); margin-right: 5px; }
.tl-item.done { background: color-mix(in srgb, var(--ok) 14%, transparent); border-color: transparent; color: var(--ok); }
.tl-item.done .n { color: var(--ok); }
.tl-item.current { background: var(--acc); border-color: transparent; color: #14181f; font-weight: 700; }
.tl-item.current .n { color: #14181f; }

.progress-line { height: 3px; background: var(--bg-3); }
.progress-line > i { display: block; height: 100%; background: var(--acc); transition: width .3s ease; }

/* --- karta ćwiczenia -----------------------------------------------------*/
.exhead { padding: 16px 14px 0; max-width: 720px; margin: 0 auto; }
.exhead .kicker { font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--acc); }
.exhead h2 { margin: 4px 0 6px; font-size: 23px; line-height: 1.2; letter-spacing: -.02em; }
.exhead .muscles { margin: 0; font-size: 13px; color: var(--txt-2); }

.panel {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--rad); padding: 14px; margin: 14px 0;
}
.panel h4 {
  margin: 0 0 8px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--txt-3);
}
.panel ol, .panel ul { margin: 0; padding-left: 18px; }
.panel li { margin-bottom: 6px; font-size: 14.5px; }
.panel li:last-child { margin-bottom: 0; }
.panel p { margin: 0; font-size: 14.5px; }

.panel.tips { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.panel.tips h4 { color: var(--ok); }
.panel.mistake { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.panel.mistake h4 { color: var(--bad); }
.panel.note { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.panel.note h4 { color: var(--warn); }

/* --- figura --------------------------------------------------------------*/
.figwrap { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--rad);
  padding: 6px 6px 0; margin: 14px 0; }
.figure { width: 100%; height: auto; display: block; }
.figure .bd { stroke: var(--txt); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.figure .bd circle { fill: none; }
.figure .eq { stroke: var(--acc); stroke-width: 3.5; stroke-linecap: round; fill: none; }
.figure .eq rect { fill: color-mix(in srgb, var(--acc) 25%, transparent); }
.figure .fl { stroke: var(--line); stroke-width: 3; }
.figure .ar { stroke: var(--ok); stroke-width: 3; fill: none; stroke-linecap: round; }
.figure .ar[marker-end] { marker-end: url(#fig-arrow); }
.figure .sp { stroke: var(--txt-3); stroke-width: 2.5; stroke-linecap: round; fill: none; }
.figure marker path { fill: var(--ok); }
.figure .lb { fill: var(--txt-3); font-size: 10px; text-anchor: middle; font-family: inherit; }

.vidbtn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 46px; border-radius: 12px;
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--txt); font-size: 14.5px; font-weight: 600; text-decoration: none;
}
.vidbtn:active { background: var(--line); }

/* --- serie ---------------------------------------------------------------*/
.setbar { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.setdots { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.setdot {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 9px;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
  background: var(--bg-3); color: var(--txt-3); border: 1px solid var(--line);
}
.setdot.done { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); border-color: transparent; }
.setdot.current { background: var(--acc); color: #14181f; border-color: transparent; }

.target {
  display: flex; gap: 10px; flex-wrap: wrap;
  background: var(--bg-3); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px;
}
.target div { font-size: 12px; color: var(--txt-2); }
.target b { display: block; font-size: 17px; color: var(--txt); font-weight: 700; }

/* --- pola wejściowe ------------------------------------------------------*/
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--txt-2); margin-bottom: 6px; }
.stepper { display: flex; gap: 8px; align-items: stretch; }
.stepper button {
  width: 56px; flex: 0 0 56px; border-radius: 12px;
  background: var(--bg-3); border: 1px solid var(--line);
  font-size: 22px; font-weight: 600; color: var(--txt);
}
.stepper button:active { background: var(--line); }
.stepper input {
  flex: 1; min-width: 0; height: var(--tap); text-align: center;
  font-size: 22px; font-weight: 700;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px;
}
.stepper input:focus { outline: 2px solid var(--acc); outline-offset: -2px; }
.stepper .unit { align-self: center; font-size: 13px; color: var(--txt-3); width: 34px; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  flex: 1 1 0; min-width: 46px; min-height: 46px; border-radius: 12px;
  background: var(--bg-3); border: 1px solid var(--line);
  font-size: 15px; font-weight: 700; color: var(--txt-2);
  display: grid; place-items: center;
}
.pill.on { background: var(--acc); color: #14181f; border-color: transparent; }
.pill small { display: block; font-size: 9.5px; font-weight: 600; opacity: .8; }

/* --- timer ---------------------------------------------------------------*/
.timer { text-align: center; padding: 6px 0 2px; }
.timer .big {
  font-size: 62px; font-weight: 750; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.05;
}
.timer .sub { font-size: 13px; color: var(--txt-2); }
.ring { display: block; margin: 0 auto; }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .bg { stroke: var(--bg-3); }
.ring .fg { stroke: var(--acc); transition: stroke-dashoffset .3s linear; }

/* --- przyciski -----------------------------------------------------------*/
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap); border-radius: 14px;
  font-size: 16px; font-weight: 700; letter-spacing: -.01em;
  background: var(--acc); color: #14181f;
}
.btn:active { filter: brightness(.92); }
.btn.sec { background: var(--bg-3); color: var(--txt); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--txt-2); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ok { background: var(--ok); color: #10241a; }
.btn[disabled] { opacity: .4; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.bottombar {
  position: sticky; bottom: 0; z-index: 25;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
  max-width: 720px; margin: 0 auto;
}

/* --- przerwa (overlay) ---------------------------------------------------*/
.rest {
  position: fixed; inset: 0; z-index: 60; display: none;
  flex-direction: column; background: var(--bg);
  padding: calc(18px + var(--safe-t)) 14px calc(14px + var(--safe-b));
  overflow-y: auto;
}
.rest.is-active { display: flex; }
.rest .lbl { text-align: center; font-size: 12px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--txt-3); }
.rest .next {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--rad); padding: 12px 14px; margin-top: 14px;
}
.rest .next .k { font-size: 11.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--acc); }
.rest .next h3 { margin: 3px 0 4px; font-size: 18px; letter-spacing: -.01em; }
.rest .next p { margin: 0; font-size: 13px; color: var(--txt-2); }
.rest-details { margin-top: 10px; }
.rest-details[hidden] { display: none; }

/* --- historia / podsumowanie --------------------------------------------*/
.hrow {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px; margin-bottom: 8px;
}
.hrow .h-main { flex: 1; min-width: 0; }
.hrow h4 { margin: 0; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hrow .h-sub { font-size: 12px; color: var(--txt-2); }
.hrow .mini {
  flex: 0 0 auto; min-height: 38px; padding: 0 12px; border-radius: 10px;
  background: var(--bg-3); border: 1px solid var(--line); font-size: 13px; font-weight: 600;
}

table.sum { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.sum th, table.sum td { padding: 7px 6px; text-align: left; border-bottom: 1px solid var(--line); }
table.sum th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--txt-3); font-weight: 700; }
table.sum td.num { text-align: right; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 21px; font-weight: 750; letter-spacing: -.02em; }
.stat span { font-size: 11px; color: var(--txt-2); }

/* --- modal ---------------------------------------------------------------*/
.modal { position: fixed; inset: 0; z-index: 80; display: none;
  align-items: flex-end; background: rgba(0,0,0,.6); }
.modal.is-active { display: flex; }
.sheet {
  width: 100%; max-width: 720px; margin: 0 auto;
  background: var(--bg-2); border-top-left-radius: 22px; border-top-right-radius: 22px;
  padding: 8px 14px calc(16px + var(--safe-b)); max-height: 88dvh; overflow-y: auto;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 14px; }
.sheet h3 { margin: 0 0 12px; font-size: 17px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: var(--tap); padding: 0 4px; font-size: 15.5px; font-weight: 600;
  border-bottom: 1px solid var(--line); text-align: left;
}
.menu-item:last-child { border-bottom: none; }
.menu-item .em { font-size: 19px; width: 26px; text-align: center; }
.menu-item.danger { color: var(--bad); }
.switch-row { display: flex; align-items: center; justify-content: space-between;
  min-height: 46px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.switch { width: 50px; height: 30px; border-radius: 999px; background: var(--bg-3);
  border: 1px solid var(--line); position: relative; flex: 0 0 50px; }
.switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--txt-3); transition: .18s; }
.switch.on { background: color-mix(in srgb, var(--ok) 35%, transparent); border-color: transparent; }
.switch.on i { left: 25px; background: var(--ok); }

.hint { font-size: 12.5px; color: var(--txt-3); margin: 8px 0 0; }
.empty { text-align: center; color: var(--txt-3); font-size: 14px; padding: 18px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--txt);
  padding: 11px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

@media (min-width: 560px) {
  .stat-grid { grid-template-columns: repeat(5, 1fr); }
}

/* --- logowanie / progresja / statystyki ---------------------------------*/
.pill.bad { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); border-color: transparent; }
#login-code:focus { outline: 2px solid var(--acc); outline-offset: -2px; }
#st-ex { width: 100%; min-height: 46px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 10px; color: var(--txt); font: inherit; }
.rec-line { font-size: 13.5px; color: var(--txt-2); margin: 0 0 4px; }
.rec-line b { color: var(--txt); }

/* --- osiągnięcia -------------------------------------------------------*/
.ach-card { display: flex; gap: 12px; align-items: flex-start; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 8px; }
.ach-card.shame { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.ach-ico { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center;
  font-size: 22px; border-radius: 12px; background: var(--bg-3); border: 2px solid var(--line); }
.ach-ico.t-0 { border-color: #a97c50; }
.ach-ico.t-1 { border-color: #8d99ae; }
.ach-ico.t-2 { border-color: #cd7f32; }
.ach-ico.t-3 { border-color: #c9ced6; }
.ach-ico.t-4 { border-color: #e9c46a; background: color-mix(in srgb, #e9c46a 14%, var(--bg-3)); }
.ach-main { flex: 1; min-width: 0; }
.ach-main h4 { margin: 0 0 2px; font-size: 14.5px; }
.chip.t-0 { color: #a97c50; } .chip.t-1 { color: #9aa7b8; } .chip.t-2 { color: #cd7f32; }
.chip.t-3 { color: #c9ced6; } .chip.t-4 { color: #e9c46a; }
.ach-bar { height: 6px; border-radius: 3px; background: var(--bg-3); margin: 7px 0 4px; overflow: hidden; }
.ach-bar i { display: block; height: 100%; background: var(--acc); }
