/* Ciśnienie opon — pitbike.
   Design targets a phone held in a paddock: sunlight, gloves, hurry.
   Hence: high contrast, 52px touch targets, huge result numbers, no clutter. */

:root {
  --bg: #0f1216;
  --surface: #171c23;
  --surface-2: #1e242d;
  --line: #2b333f;
  --text: #eef2f7;
  --muted: #9aa7b8;
  --accent: #e8000d;          /* Radwan Racing Team */
  --accent-ink: #ffffff;
  --ok: #3ddc84;
  --warn: #ffc857;
  --radius: 14px;
  --tap: 52px;
  --pad: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --line: #d3dae4;
    --text: #10151c;
    --muted: #5b6779;
    --accent: #c4000b;        /* przyciemnione dla kontrastu na bieli */
    --accent-ink: #ffffff;
    --ok: #0d8f4f;
    --warn: #9a6a00;
  }
}

* { box-sizing: border-box; }

/* An explicit `display` in a component rule beats the UA style for [hidden],
   so elements toggled via the attribute need this to actually disappear. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ------------------------------------------------------------------ header */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px var(--pad);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.titles { flex: 1; min-width: 0; }
.top h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.back {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.langbtn {
  min-width: 40px; height: 44px;
  flex: 0 0 auto;
  padding: 0 8px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.net {
  width: 9px; height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--ok);
}
.net.off { background: var(--muted); }

/* -------------------------------------------------------------------- main */
main { flex: 1; padding: var(--pad); max-width: 640px; width: 100%; margin: 0 auto; }
.view { animation: in 0.18s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------- brand tiles */
.brands { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  padding: 14px 16px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.brand:active { background: var(--surface-2); }
.brand .bn { font-size: 1.15rem; font-weight: 680; letter-spacing: -0.01em; }
.brand .bd { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }
.brand .chev { margin-left: auto; color: var(--muted); font-size: 1.2rem; }

/* ------------------------------------------------------------------- forms */
fieldset { border: 0; margin: 0 0 18px; padding: 0; }
legend {
  padding: 0 0 8px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.field { margin-bottom: 12px; }
.field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 560;
}
.hint { font-size: 0.78rem; color: var(--muted); font-weight: 400; }
/* Znacznik pola do uzupelnienia. Jest w kazdym polu od poczatku, ale widac go
   dopiero, gdy pole naprawde jest puste — dzieki temu przelaczanie widocznosci
   nie wymaga przebudowy formularza (patrz `paint()` w app.js). */
.req {
  display: none;
  margin-left: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: lowercase;
}
.field.missing .req { display: inline; }
.field.missing select,
.field.missing input[type="number"] { border-color: var(--accent); }

/* Lista brakow pod formularzem: zawodnik ma od razu wiedziec, CZEGO brakuje,
   zamiast zgadywac, czy aplikacja dziala. Kazda pozycja prowadzi do pola. */
.missing-box { padding: 4px 0; }
.missing-box > strong { display: block; margin-bottom: 10px; font-size: 0.98rem; }
.missing-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; padding: 0; }
.jump {
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 999px;
}

select, input[type="number"] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
select:disabled { opacity: 0.45; }

/* segmented choices — faster than a dropdown with a glove on */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto;
  min-width: 88px;
  min-height: var(--tap);
  padding: 0 12px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 560;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seg button[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}
.seg.dim button { font-size: 0.9rem; }

/* ------------------------------------------------------------------ result */
.result {
  margin-top: 4px;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.axles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.axle {
  padding: 14px 12px;
  text-align: center;
  background: var(--surface-2);
  border-radius: 12px;
}
.axle .lab {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Pojedyncza wartość („1.73") mieści się w 2.5rem, ale zakres Pirelli („1.3/1.4")
   już nie — przy dwóch kafelkach na 390 px wychodziłby poza kartę. */
.axle .val {
  margin: 6px 0 0;
  font-size: 2.5rem;
  font-weight: 720;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.axle .val.long { font-size: 1.85rem; letter-spacing: -0.02em; }
.axle .unit { font-size: 0.95rem; font-weight: 600; color: var(--muted); margin-left: 3px; }
.axle .sub { margin-top: 7px; font-size: 0.8rem; color: var(--muted); }

.rows { margin-top: 14px; display: grid; gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  background: var(--surface);
  font-size: 0.88rem;
}
.row dt { color: var(--muted); margin: 0; }
.row dd { margin: 0; font-weight: 580; text-align: right; font-variant-numeric: tabular-nums; }

.note, .warnbox {
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.86rem;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 10px;
  color: var(--muted);
}
.warnbox {
  border-left-color: var(--warn);
  color: var(--text);
  background: color-mix(in srgb, var(--warn) 9%, var(--surface));
}
.warnbox strong { color: var(--warn); }


.foot { margin-top: 22px; font-size: 0.8rem; line-height: 1.55; color: var(--muted); }

/* Sticky result bar — the form is longer than a phone screen, so the numbers stay
   pinned while the rider tweaks weight or temperature. Tap scrolls to the details. */
.sticky {
  position: sticky;
  bottom: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 18px;
  font: inherit;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.28);
}
.sticky .sv { display: flex; align-items: baseline; gap: 7px; }
.sticky em {
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.72;
}
.sticky b { font-size: 1.6rem; font-weight: 720; line-height: 1; font-variant-numeric: tabular-nums; }
.sticky .sunit { margin-left: auto; font-size: 0.78rem; font-weight: 600; opacity: 0.8; white-space: nowrap; }
.sticky b.long { font-size: 1.25rem; }

/* --------------------------------------------------------------- team brand */
.teamhead {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 16px 20px;
  margin-bottom: 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
}
.teamhead img { width: min(210px, 62%); height: auto; }
.teamhead .tag {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.teamhead .blurb { margin: 0; font-size: 0.82rem; color: var(--muted); max-width: 42ch; }

.teammark { display: flex; align-items: center; gap: 8px; }
.teammark img { height: 22px; width: auto; }

/* ------------------------------------------------------------------ promos */
.promo {
  display: block;
  margin-top: 16px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
}
.promo:active { background: var(--surface-2); }
.promo .kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.promo .kicker::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.promo h3 { margin: 7px 0 0; font-size: 0.98rem; font-weight: 650; }
.promo p { margin: 5px 0 0; font-size: 0.84rem; line-height: 1.45; color: var(--muted); }
.promo .cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--accent);
}
.promo .code {
  display: inline-block;
  margin-top: 10px;
  margin-right: 10px;
  padding: 4px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 7px;
}

/* ---------------------------------------------------------------- feedback */
.fb {
  margin-top: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 12px;
}
.fb h3 { margin: 0; font-size: 0.96rem; font-weight: 650; }
.fb p { margin: 6px 0 0; font-size: 0.84rem; line-height: 1.5; color: var(--muted); }
.fb .fbbtn {
  display: inline-block;
  min-height: 46px;
  margin-top: 12px;
  padding: 12px 20px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 11px;
}
.fb .fbmail {
  display: block;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
.fb .fbmail a {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

/* ------------------------------------------------------------------ footer */
.bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--pad);
  border-top: 1px solid var(--line);
  background: var(--bg);
}
/* Ostatni wiersz aplikacji — autorstwo. Osobna linia, a nie kolejny element
   w pasku stopki: ten jest flexem i przy trzech elementach lamie sie na waskim
   telefonie. Stad tez tutaj, a nie w pasku, siedzi margines bezpieczny iOS. */
.author {
  padding: 0 var(--pad) calc(12px + env(safe-area-inset-bottom));
  font-size: 0.72rem;
  text-align: center;
  color: var(--muted);
  background: var(--bg);
}
.author a { color: var(--muted); }
/* Wersja w osobnym wierszu i słabszym kolorem: to informacja serwisowa, nie treść. */
.author .ver { display: block; margin-top: 3px; opacity: 0.75; font-variant-numeric: tabular-nums; }
.ghost {
  min-height: 40px;
  padding: 0 16px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.src { margin-left: auto; font-size: 0.72rem; color: var(--muted); text-align: right; }
.teamlink {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.teamlink img { height: 16px; width: auto; opacity: 0.85; }
.src a { color: var(--muted); }

button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* Kafelki marek zawsze w jednej kolumnie — na telefonie łatwiej trafić palcem,
   a na szerszym ekranie i tak ogranicza je `max-width` kontenera. */
@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
}
