:root {
  /* Układ: jedna kolumna, ciemny pas "asfaltu" u góry z przerywaną linią, karty kursów, przyklejony pasek zapisu. */
  --bg: #edf0ec;
  --surface: #ffffff;
  --ink: #10252b;
  --muted: #566b70;
  --line: #d3dbd7;
  --road: #12262b;
  --road-ink: #f3f6f4;
  --accent: #f5b800;
  --accent-ink: #10252b;
  --ok: #17663f;
  --ok-bg: #dcf1e5;
  --warn: #7a4600;
  --warn-bg: #fbe9c3;
  --bad: #a8231b;
  --bad-bg: #fadcd8;
  --mine-bg: #fff1bd;
  --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c171a;
    --surface: #15262b;
    --ink: #e9f1ee;
    --muted: #93a8ab;
    --line: #26403f;
    --road: #081013;
    --ok: #6fd69b;
    --ok-bg: #123324;
    --warn: #f3c15a;
    --warn-bg: #3a2d0c;
    --bad: #ff9a91;
    --bad-bg: #3d1714;
    --mine-bg: #3b3208;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c171a;
  --surface: #15262b;
  --ink: #e9f1ee;
  --muted: #93a8ab;
  --line: #26403f;
  --road: #081013;
  --ok: #6fd69b;
  --ok-bg: #123324;
  --warn: #f3c15a;
  --warn-bg: #3a2d0c;
  --bad: #ff9a91;
  --bad-bg: #3d1714;
  --mine-bg: #3b3208;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body.has-bar .foot { padding-bottom: 200px; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; letter-spacing: 0.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Nagłówek */
.top {
  background: var(--road);
  color: var(--road-ink);
  padding: env(safe-area-inset-top) 16px 0;
  position: relative;
}
.top::after {
  content: "";
  display: block;
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 18px, transparent 18px 30px);
  opacity: 0.9;
}
.top-row {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}
.chip {
  border: 1.5px solid rgba(243, 246, 244, 0.45);
  background: transparent;
  color: var(--road-ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.demo {
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.85rem;
  padding: 8px 16px;
  text-align: center;
}

main { max-width: 560px; margin: 0 auto; padding: 18px 16px 28px; display: flex; flex-direction: column; gap: 16px; }

/* Przyciski */
.primary {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 14px 18px;
  min-height: 52px;
  cursor: pointer;
}
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.secondary {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 46px;
}
.secondary.danger { color: var(--bad); }
.link {
  background: none;
  border: 0;
  padding: 8px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}
.link.danger { color: var(--bad); }

/* Nagłówek sekcji */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sec-head .secondary { padding: 8px 14px; min-height: 40px; }
.muted { color: var(--muted); }

/* Karta kursu */
.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 4px 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  text-decoration: none;
}
.card:active { transform: scale(0.99); }
.date {
  display: grid;
  justify-items: center;
  background: var(--road);
  color: var(--road-ink);
  border-radius: 10px;
  padding: 6px 0 7px;
  line-height: 1;
}
.date .dow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; }
.date .day { font-family: var(--font-display); font-weight: 700; font-size: 2rem; margin: 2px 0; font-variant-numeric: tabular-nums; }
.date .mon { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.info { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.time { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.label { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.count { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.count b { font-size: 2rem; color: var(--ink); line-height: 1; }
.card .pillrow { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 6px; }

/* Wskaźniki zapełnienia busów */
.meters { display: flex; gap: 8px; }
.mg { display: grid; grid-template-columns: repeat(9, 5px); gap: 2px; }
.mg i { display: block; height: 14px; border-radius: 1.5px; background: var(--line); }
.mg i.f { background: var(--ink); }
.mg.extra i.f { background: var(--bad); }
.mg.extra i { background: var(--bad-bg); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.85rem;
  font-weight: 600;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.idle { background: var(--line); color: var(--muted); }

details.past summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 8px 0; }
details.past .cards { margin-top: 8px; opacity: 0.8; }

.empty, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel label { font-weight: 600; font-size: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 6px; }
input[type="text"], input[type="date"], input[type="time"], input[type="password"] {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
  color: var(--ink);
}
.err { color: var(--bad); font-weight: 600; font-size: 0.9rem; }

/* Widok kursu */
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--muted); font-weight: 600; padding: 4px 0; }
.trip-head { display: flex; flex-direction: column; gap: 4px; }
.trip-head h1 { font-size: 2rem; line-height: 1.05; }
.trip-head h1::first-letter { text-transform: uppercase; }
.trip-head .sub { color: var(--muted); }
.summary {
  background: var(--road);
  color: var(--road-ink);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.summary .big { font-family: var(--font-display); font-weight: 700; font-size: 3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.summary .big small { font-size: 1.4rem; opacity: 0.65; }
.summary .of { opacity: 0.8; }
.summary .pill.ok { background: #dcf1e5; color: #17663f; }
.summary .pill.warn { background: #fbe9c3; color: #7a4600; }
.summary .pill.bad { background: #fadcd8; color: #a8231b; }
.summary .pill.idle { background: rgba(243, 246, 244, 0.18); color: var(--road-ink); }
.summary .pill { align-self: flex-start; }

.bus { display: flex; flex-direction: column; gap: 8px; }
.bus-head { display: flex; align-items: baseline; justify-content: space-between; }
.bus-head .n { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.bus.extra h3 { color: var(--bad); }
.seats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seat {
  min-height: 58px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  background: transparent;
}
.seat .sn { font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.seat .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-weight: 500; }
.seat.taken { border-style: solid; border-color: var(--ink); background: var(--surface); }
.seat.taken .nm { color: var(--ink); font-weight: 600; }
.seat.mine { background: var(--mine-bg); border-color: var(--accent); }
.bus.extra .seat.taken { border-color: var(--bad); }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list .who b { overflow-wrap: anywhere; }
.list .who small { color: var(--muted); }
.list li.mine { background: var(--mine-bg); border-radius: 14px; }
.admin-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Pasek zapisu */
.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.08);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}
.bar-row { display: flex; gap: 10px; }
.bar-row input { flex: 1; min-width: 0; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); }
.stepper button { width: 42px; height: 46px; border: 0; background: none; font-size: 1.4rem; cursor: pointer; }
.stepper output { min-width: 22px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.hint { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.hint.bad { color: var(--bad); }

.foot { max-width: 560px; margin: 0 auto; padding: 0 16px 28px; display: flex; justify-content: space-between; gap: 12px; }

/* Okno dialogowe */
dialog {
  border: 0;
  border-radius: 16px;
  padding: 20px;
  width: min(92vw, 440px);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
dialog::backdrop { background: rgba(8, 16, 19, 0.6); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog .row { display: flex; gap: 10px; }
dialog .row > * { flex: 1; }
dialog .check { flex-direction: row; align-items: flex-start; gap: 10px; }
dialog .check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); }
.menu-btn { text-align: left; width: 100%; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 24px;
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 600;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
body.has-bar .toast { bottom: 190px; }

.pill.mine { background: var(--mine-bg); color: var(--ink); }
.code { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; background: var(--bg); border: 1.5px solid var(--line); border-radius: 8px; padding: 2px 10px; }
.list li.boarded .who b::after { content: " ✓"; color: var(--ok); }
.codebig { font-family: var(--font-display); font-weight: 700; font-size: 4rem; letter-spacing: 0.18em; text-align: center; line-height: 1; padding: 8px 0; font-variant-numeric: tabular-nums; }
.install { background: var(--surface); border: 1.5px solid var(--accent); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.install > b { font-family: var(--font-display); font-size: 1.3rem; }
.install ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.install .link { align-self: flex-start; padding-left: 0; }
.install-pop { display: flex; flex-direction: column; gap: 12px; }
.install-pop ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.install-pop .row { align-items: center; }
.datebar { display: flex; flex-direction: column; gap: 6px; }
.datebar label { font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.datebar .row { display: flex; gap: 8px; }
.datebar .row input { flex: 1; }
.count .free { display: block; font-family: var(--font-body); font-size: 0.8rem; font-weight: 600; color: var(--ok); }
.count .free.none { color: var(--bad); }

@media (prefers-reduced-motion: no-preference) {
  .card { transition: transform 0.08s ease; }
}
