/* StoPompek — ciemny motyw o wysokim kontraście. Ekran czyta się z podłogi,
   z odległości wyciągniętej ręki, więc liczby są duże, a podpisy krótkie. */

:root {
  --bg: #0b0f14;
  --bg2: #121821;
  --card: #161e29;
  --line: #223041;
  --fg: #eef4fb;
  --dim: #8ea2b8;
  --accent: #4f8cff;
  --accent2: #85b0ff;
  --ok: #2fd97a;
  --warn: #ffcb3d;
  --bad: #ff4d5e;
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  padding-bottom: calc(64px + var(--safe-b));
  overscroll-behavior-y: contain;
}

h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 21px; margin: 0 0 8px; letter-spacing: -0.02em; }
a { color: var(--accent2); }
.hidden { display: none !important; }

/* ---------- pasek górny ---------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
}
.brand { background: none; border: 0; color: var(--fg); font-weight: 800; font-size: 19px; letter-spacing: -0.03em; }
.brand span { color: var(--accent); }
.brand em { font-style: normal; font-size: 11px; color: var(--dim); margin-left: 6px; font-weight: 600; }
#top-state { margin-left: auto; }

main { padding: 0 16px; }
.view { display: none; animation: fade .18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.hero { margin: 6px 0 16px; }
.hero p { color: var(--dim); margin: 0; }
.back { background: none; border: 0; color: var(--dim); font-size: 15px; padding: 8px 0; margin-bottom: 4px; }

/* ---------- elementy wspólne ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px; margin-bottom: 14px;
}
.accent-card { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(79,140,255,.18), 0 8px 30px -18px var(--accent); }
.card-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--dim); margin-bottom: 10px; font-weight: 600;
}
.desc { color: var(--dim); margin: 0 0 14px; }
.hint { color: var(--dim); font-size: 13px; margin: 8px 0 0; }
.note {
  background: #3a2a10; border: 1px solid #6b4d16; color: var(--warn);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 14px;
}
.note.dobra { background: #0e2f1d; border-color: #1c5c38; color: #9ff0c4; }
.lista { margin: 0; padding-left: 18px; color: var(--dim); font-size: 14px; }
.lista li { margin-bottom: 6px; }
.lista li:last-child { margin-bottom: 0; }

button { font-family: inherit; cursor: pointer; }
.primary, .danger, .ghost {
  border-radius: 12px; border: 1px solid transparent;
  padding: 12px 16px; font-size: 15px; font-weight: 600;
}
.primary { background: var(--accent); color: #04122e; }
.primary:active { background: var(--accent2); }
.danger { background: var(--bad); color: #2a0409; }
.ghost { background: transparent; border-color: var(--line); color: var(--fg); }
.ghost:active { background: var(--bg2); }
.big { display: block; width: 100%; padding: 16px; font-size: 17px; margin-bottom: 14px; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row > * { flex: 1 1 auto; }

.chip {
  background: var(--bg2); border: 1px solid var(--line); color: var(--dim);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.chip-action { color: var(--fg); }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.meta-row span {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; color: var(--dim);
}
.meta-row span b { color: var(--fg); }

.kv { font-size: 14px; line-height: 1.7; }
.kv b { color: var(--accent2); }

/* ---------- postęp w programie ---------- */
.pr-grid { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 6px; align-items: center; }
.pr-week { font-size: 12px; color: var(--dim); padding-right: 4px; }
.pr-day {
  height: 30px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 11px; color: var(--dim);
}
.pr-day.done { background: rgba(47,217,122,.16); border-color: var(--ok); color: var(--ok); }
.pr-day.now { background: var(--accent); border-color: var(--accent); color: #04122e; font-weight: 700; }
.pr-day.test { border-style: dashed; }
#pr-line { margin-top: 10px; }

/* ---------- tabela tygodnia ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.tbl th, table.tbl td { padding: 7px 6px; text-align: center; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
table.tbl td:first-child, table.tbl th:first-child { text-align: left; color: var(--dim); }
table.tbl td.kol { color: var(--fg); font-weight: 700; }
table.tbl col.aktywna, table.tbl td.aktywna, table.tbl th.aktywna { background: rgba(79,140,255,.12); }
table.tbl th.aktywna { color: var(--accent2); }
table.tbl tr.dzien-head td { color: var(--accent2); font-weight: 700; text-align: left; padding-top: 12px; }

/* ---------- lista serii ---------- */
.seg-list { display: grid; gap: 6px; }
.seg {
  display: grid; grid-template-columns: 4px 1fr auto auto; gap: 10px;
  align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.seg:last-child { border-bottom: 0; }
.seg i { width: 4px; height: 24px; border-radius: 2px; background: var(--line); }
.seg.zrobiona i { background: var(--ok); }
.seg.biezaca i { background: var(--accent); }
.seg .nm { font-size: 14px; }
.seg.biezaca .nm { font-weight: 700; }
.seg .sp { font-variant-numeric: tabular-nums; font-weight: 700; }
.seg .tm { color: var(--dim); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; font-size: 13px; }
.seg .tm.lepiej { color: var(--ok); }
.seg .tm.gorzej { color: var(--warn); }

/* ---------- ekran sesji ---------- */
.run-head { text-align: center; margin: 4px 0 8px; }
.kind { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent2); font-weight: 700; }
.seg-label { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }

.ring-wrap { position: relative; width: min(72vw, 280px); margin: 8px auto 14px; }
#ring { width: 100%; display: block; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg2); stroke-width: 12; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 503; stroke-dashoffset: 503; transition: stroke-dashoffset .25s linear;
}
.seg-arc { fill: none; stroke-width: 7; stroke-linecap: butt; }
.seg-arc-bg { stroke: var(--line); }
.seg-arc-fg { stroke: var(--ok); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.bignum {
  font-size: 66px; font-weight: 800; font-variant-numeric: tabular-nums;
  letter-spacing: -.04em; line-height: 1;
}
.bigedit {
  background: none; border: 0; border-bottom: 2px dashed var(--line); color: var(--fg);
  width: 3.2em; text-align: center; padding: 0; font-family: inherit;
}
.bigedit:focus { outline: none; border-bottom-color: var(--accent); }
.bigedit::-webkit-outer-spin-button, .bigedit::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bigedit { -moz-appearance: textfield; }
.ring-sub { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; margin-top: 6px; }

.counter { display: grid; grid-template-columns: 1fr 1.8fr 1fr; gap: 8px; margin-bottom: 12px; }
.ctl {
  background: var(--card); border: 1px solid var(--line); color: var(--fg);
  border-radius: 12px; padding: 16px 6px; font-size: 16px; font-weight: 700;
}
.ctl:active { background: var(--bg2); }
.ctl.primary { background: var(--accent); color: #04122e; border-color: var(--accent); }
.ctl.primary:active { background: var(--accent2); }

.next {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 14px; color: var(--dim); margin-bottom: 12px; text-align: center;
}
.next b { color: var(--fg); }

/* ---------- kafelki ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.big-tiles { grid-template-columns: repeat(2, 1fr); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center; }
.tv { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tl { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

/* ---------- historia ---------- */
.hist-list { display: grid; gap: 10px; margin-bottom: 14px; }
.hist {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  text-align: left; color: var(--fg); width: 100%;
}
.hist-top {
  /* Trzy kolumny, bo strzałka ::after też jest elementem siatki — przy dwóch
     spadała do drugiego wiersza, pod datę. */
  display: grid; grid-template-columns: 1fr auto auto; gap: 4px; align-items: center;
  width: 100%; background: none; border: 0; padding: 0; color: inherit; text-align: left;
}
/* Strzałka mówi, że wpis się rozwija — bez niej nikt by nie zgadł, że jest tam
   coś jeszcze, a to jedyne miejsce, w którym da się poprawić liczby. */
.hist-top::after { content: '⌄'; color: var(--dim); margin-left: 8px; font-size: 14px; }
.hist.open .hist-top::after { content: '⌃'; }
.hist-det { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.hist-meta { color: var(--dim); font-size: 12px; margin-top: 10px; }
.edit-list { display: grid; gap: 8px; }
.edit-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.edit-row span { font-size: 14px; }
.edit-row em { color: var(--dim); font-style: normal; font-size: 12px; }
.edit-row input {
  width: 92px; background: var(--bg2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 17px;
  font-variant-numeric: tabular-nums; text-align: center;
}
.edit-row input:focus { outline: none; border-color: var(--accent); }
.hist .nm { font-weight: 600; }
.hist .dt { color: var(--dim); font-size: 12px; }
.hist .st { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.hist .st small { display: block; font-size: 10px; color: var(--dim); font-weight: 500; text-transform: uppercase; }
.hist.dnf { opacity: .6; }
.hist.test { border-left: 4px solid var(--accent); }

.chart { display: flex; align-items: flex-end; justify-content: center; gap: 6px; height: 120px; }
/* Bez górnego ograniczenia jeden test daje słupek na całą szerokość karty —
   wygląda jak kolorowy prostokąt, a nie jak wykres. */
.chart .bar { flex: 1; max-width: 54px; background: var(--accent); border-radius: 4px 4px 0 0; position: relative; min-height: 4px; }
.chart .bar span {
  position: absolute; top: -18px; left: 0; right: 0; text-align: center;
  font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums;
}
.chart .bar em {
  position: absolute; bottom: -18px; left: 0; right: 0; text-align: center;
  font-size: 10px; color: var(--dim); font-style: normal;
}
.chart.pusty { color: var(--dim); font-size: 13px; align-items: center; height: auto; }
#hist-chart-note { margin-top: 26px; }

/* ---------- ustawienia ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; margin-bottom: 8px; }
.field em { color: var(--dim); font-style: normal; font-size: 12px; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); height: 28px; }
.range-row b { font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; font-size: 17px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 15px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
/* Wybór jedną z kilku wartości. Pola dotyku większe niż w pastylkach filtrów,
   bo ten wybór trafia się raz na kilka tygodni i ma być trafiony za pierwszym
   razem, a nie „prawie". */
.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice .chip { padding: 11px 16px; font-size: 14px; }
.choice .chip.active { background: var(--accent); border-color: var(--accent); color: #04122e; }

/* ---------- historia zmian ---------- */
.cl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cl-head b { font-size: 17px; }
.cl-date { color: var(--dim); font-size: 12px; margin-left: auto; }
.cl-now { font-size: 10px; background: var(--accent); color: #04122e; border-radius: 999px; padding: 2px 8px; font-weight: 700; }
.cl-title { font-weight: 600; margin-bottom: 8px; }
.cl-changes { margin: 0; padding-left: 18px; color: var(--dim); font-size: 14px; }
.cl-changes li { margin-bottom: 6px; }

/* ---------- nawigacja dolna ---------- */
#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg2); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab { background: none; border: 0; color: var(--dim); padding: 14px 4px; font-size: 12px; font-weight: 600; }
.tab.active { color: var(--accent); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(76px + var(--safe-b)); z-index: 60;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; opacity: 0; transform: translateY(8px);
  transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-color: var(--bad); color: #ffd9dd; }

/* ---------- układ poziomy i niskie ekrany ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  /* W poziomie pasek zakładek zabiera jedną trzecią wysokości ekranu sesji,
     a w trakcie treningu i tak się z niego nie korzysta. */
  body:has(#view-run.active) #tabs { display: none; }
  body:has(#view-run.active) { padding-bottom: 8px; }
  #view-run.active {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 18px; align-items: center;
  }
  #view-run .run-head { grid-column: 1 / -1; }
  #view-run .ring-wrap { width: min(38vw, 220px); margin: 0 auto; }
  #view-run #run-list { max-height: 40vh; overflow: auto; }
}
