:root {
  --ink: #111418;
  --ink-2: #3b4249;
  --muted: #6c757d;
  --line: #e4e6e8;
  --bg: #ffffff;
  --bg-2: #f3f4f5;
  --go: #16a362;
  --go-bg: #e6f6ee;
  --stop: #d03b2f;
  --link: #1f5fbf;
  --r: 12px;
  --shadow: 0 -2px 18px rgba(17, 20, 24, .12);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f1f3f5; --ink-2: #c4cad0; --muted: #8c959e; --line: #2a3036;
    --bg: #15181c; --bg-2: #1e2227; --go-bg: #12301f; --link: #7fb0ff; --shadow: 0 -2px 18px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg-2);
  font-variant-numeric: tabular-nums;
}
button, input, select { font: inherit; color: inherit; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#map { position: fixed; inset: 0; }
.hidden { display: none !important; }

/* górny pasek */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + var(--safe-t)) 12px 10px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 8px; border: 0; background: var(--bg);
  padding: 5px 12px 5px 5px; border-radius: 10px; font-weight: 700; font-size: 15px;
  box-shadow: 0 1px 6px rgba(0,0,0,.14); cursor: pointer;
}
.brand img { width: 28px; height: 28px; border-radius: 7px; display: block; }
.topright { display: flex; gap: 8px; align-items: center; }
.chip {
  border: 0; background: var(--bg); padding: 0 12px; height: 38px; border-radius: 10px; font-weight: 700; font-size: 15px;
  box-shadow: 0 1px 6px rgba(0,0,0,.14); cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 10px; border: 0; padding: 0;
  background: var(--ink) center/cover; color: var(--bg); box-shadow: 0 1px 6px rgba(0,0,0,.14); cursor: pointer; font-weight: 700;
}

/* arkusz */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  max-height: 72vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  padding: 4px 16px calc(16px + var(--safe-b));
}
@media (min-width: 720px) {
  .sheet { left: 16px; right: auto; width: 400px; bottom: 16px; border-radius: 16px; max-height: calc(100vh - 96px); }
}
.grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 12px; }
h1 { font-size: 22px; line-height: 1.2; margin: 2px 0 6px; letter-spacing: -.015em; font-weight: 700; }
h2 { font-size: 13px; margin: 22px 0 6px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
p { margin: 6px 0; }
.lead { color: var(--ink-2); }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }

/* przyciski */
.btn {
  display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 14px 16px; font-weight: 650; font-size: 16px;
  background: var(--ink); color: var(--bg); cursor: pointer; margin-top: 10px; text-decoration: none;
}
.btn:disabled { opacity: .35; cursor: default; }
.btn.go { background: var(--go); color: #fff; }
.btn.ghost { background: var(--bg-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--stop); border: 1px solid var(--line); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.linkbtn { border: 0; background: none; padding: 8px 0; color: var(--link); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.back { border: 0; background: none; padding: 4px 0 6px; color: var(--muted); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; }

/* opcje (wybór roli) */
.opts { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; border: 0; background: var(--bg);
  text-align: left; cursor: pointer; border-bottom: 1px solid var(--line);
}
.opt:last-child { border-bottom: 0; }
.opt .ib { width: 44px; height: 44px; border-radius: 10px; background: var(--ink); color: var(--bg); display: grid; place-items: center; flex: none; }
.opt .ib svg.i { width: 24px; height: 24px; }
.opt .grow { flex: 1; }
.opt b { display: block; font-size: 17px; }
.opt span.muted { font-size: 14px; }

/* pola */
.field { margin-top: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.input {
  width: 100%; border: 1px solid var(--line); background: var(--bg-2); border-radius: 10px;
  padding: 12px 13px; outline: none; font-size: 16px;
}
.input:focus { border-color: var(--ink-2); background: var(--bg); }
.picked {
  display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.picked .grow { flex: 1; min-width: 0; }
.picked b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picked .muted { font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picked .change { color: var(--link); font-weight: 600; font-size: 14px; }
.list { list-style: none; padding: 0; margin: 4px 0 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .grow .muted { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sq { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--bg-2); color: var(--ink-2); flex: none; }
.sq svg.i { width: 17px; height: 17px; }
.favs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fav { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 11px; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.fav svg.i { width: 16px; height: 16px; }
.hint { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; margin-top: 8px; }

.range { width: 100%; accent-color: var(--ink); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 2px; border-top: 1px solid var(--line); margin-top: 14px; }
.switch input { width: 44px; height: 24px; accent-color: var(--go); flex: none; }

/* osoby, auto */
.person { display: flex; align-items: center; gap: 12px; }
.face {
  width: 48px; height: 48px; border-radius: 50%; background: var(--bg-2) center/cover; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 18px; color: var(--ink-2);
}
.person b { font-size: 17px; }
.stars { font-weight: 700; }
.plate {
  display: inline-block; font: 700 21px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .06em;
  border: 2px solid #111; border-left: 12px solid #1d4ed8; border-radius: 5px; padding: 6px 9px 5px;
  background: #fff; color: #111; margin-top: 10px;
}
.card { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-top: 12px; }
.card.offer { border: 2px solid var(--ink); animation: pop .3s ease-out; }
@keyframes pop { from { transform: translateY(6px); opacity: .3; } }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 12px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.fact { background: var(--bg); padding: 8px 10px; }
.fact b { display: block; font-size: 20px; font-weight: 700; }
.fact span { font-size: 12px; color: var(--muted); }
.stopline { display: grid; grid-template-columns: 14px 1fr; gap: 6px 10px; margin-top: 12px; align-items: start; }
.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; }
.dot.a { background: #fff; border: 3.5px solid var(--go); }
.dot.b { background: repeating-conic-gradient(#111418 0 25%, #fff 0 50%) 0 0 / 6px 6px; box-shadow: 0 0 0 1.5px var(--ink); }
.label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* stan oczekiwania */
.wait { display: flex; align-items: center; gap: 14px; margin: 6px 0; }
.spin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--ink); animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 6px; background: var(--bg-2); color: var(--ink-2); font-weight: 650; font-size: 13px; }
.badge.go { background: var(--go-bg); color: var(--go); }
.badge.go::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--go); }

/* odjazdy (jak tablica przystankowa) */
.deps { margin-top: 4px; }
.dep { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dep:last-of-type { border-bottom: 0; }
.line-no { min-width: 42px; text-align: center; font-weight: 700; border-radius: 5px; padding: 3px 6px; background: var(--ink); color: var(--bg); font-size: 14px; }
.dep .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.dep .t { font-weight: 700; }

/* profil */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 12px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rank li { cursor: default; }
.rank .pos { width: 22px; text-align: right; font-weight: 700; color: var(--muted); }
.rank li.me b { text-decoration: underline; text-underline-offset: 3px; }

/* modal i toast */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(10, 12, 14, .5); display: grid; place-items: end center; }
.modal-card { width: min(460px, 100%); background: var(--bg); border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + var(--safe-b)); }
@media (min-width: 720px) { .modal { place-items: center; } .modal-card { border-radius: 16px; } }
.rate { display: flex; justify-content: center; gap: 4px; margin: 16px 0 4px; }
.rate button { border: 0; background: none; cursor: pointer; color: var(--line); padding: 2px; }
.rate button svg { width: 38px; height: 38px; fill: currentColor; stroke: none; }
.rate button.on { color: var(--ink); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(62px + var(--safe-t)); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 15px;
  max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.gbtn { display: flex; justify-content: center; margin-top: 18px; min-height: 44px; }
.steps { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; margin: 10px 0; color: var(--ink-2); }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 6px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 13px; display: grid; place-items: center; flex: none; }
.foot { margin-top: 20px; font-size: 12px; color: var(--muted); text-align: center; }
.foot a { color: inherit; }

/* znaczniki na mapie */
.mk { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.mk.me { background: #2f6fde; border: 3px solid #fff; }
.mk.a { width: 20px; height: 20px; background: #fff; border: 5px solid #16a362; }
.mk.b { width: 22px; height: 22px; background: repeating-conic-gradient(#111418 0 25%, #fff 0 50%) 0 0 / 8px 8px; border: 3px solid #fff; box-shadow: 0 0 0 1.5px #111418, 0 1px 4px rgba(0,0,0,.35); }
.mk.dest { width: 26px; height: 26px; border-radius: 6px; background: #111418; border: 2px solid #fff; display: grid; place-items: center; color: #fff; }
.mk.dest svg.i { width: 15px; height: 15px; stroke-width: 2.2; }
.mk.car { width: 34px; height: 34px; background: #111418; border: 2px solid #fff; display: grid; place-items: center; color: #fff; }
.mk.car svg.i { width: 20px; height: 20px; }
