:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1220;
  color: #f1f5f9;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px max(18px, calc((100% - 900px)/2));
  background: #111c2e; border-bottom: 1px solid #26354b;
}
.brand { font-size: 20px; font-weight: 850; letter-spacing: 2px; }
.subtitle { color: #94a3b8; font-size: 13px; margin-top: 3px; }
.icon-button {
  border: 1px solid #34445c; border-radius: 12px; background: #1d2b40;
  color: white; font-size: 26px; width: 44px; height: 44px;
}
main { width: min(900px, 100%); margin: auto; padding: 20px 16px 40px; }
.search-section { position: relative; z-index: 10; }
label, .eyebrow { display: block; color: #94a3b8; font-size: 11px; font-weight: 750; letter-spacing: 1.2px; margin-bottom: 9px; }
input[type="search"] {
  width: 100%; padding: 16px; border: 1px solid #34445c; border-radius: 13px;
  background: #172338; color: white; outline: none; font-size: 16px;
}
input:focus { border-color: #38bdf8; }
.search-results {
  position: absolute; top: 76px; left: 0; right: 0; background: #172338;
  border: 1px solid #34445c; border-radius: 12px; overflow: hidden;
  box-shadow: 0 12px 30px #0008; max-height: 340px; overflow-y: auto;
}
.search-results:empty { display: none; }
.search-result {
  width: 100%; display: flex; justify-content: flex-start; align-items: baseline; gap: 6px;
  text-align: left; padding: 13px 15px; border: 0; border-bottom: 1px solid #2a3a50;
  background: transparent; color: white;
}
.search-result:hover { background: #263750; }
.result-name { font-weight: 700; }
.result-number { color: #94a3b8; font-size: 13px; white-space: nowrap; }
.selected-section, .departures-section, .map-section, .favorites-section {
  margin-top: 25px;
}
.hidden { display: none !important; }
.stop-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h1 { font-size: 25px; margin: 0 0 5px; }
.stop-number { color: #94a3b8; font-size: 25px; font-weight: 700; }
.favorite-button {
  border: 1px solid #475569; background: #172338; color: #fbbf24;
  border-radius: 12px; width: 48px; height: 48px; font-size: 29px;
}
.stop-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.secondary-button {
  border: 1px solid #34445c; border-radius: 10px; padding: 10px 13px;
  background: #172338; color: #dbeafe;
}
.updated { color: #64748b; font-size: 11px; }
.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
h2 { font-size: 17px; margin: 0; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.departures-list { display: grid; gap: 8px; }
.departure {
  display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 12px;
  background: #172338; border: 1px solid #26354b; border-radius: 12px; padding: 12px;
}
.line {
  display: grid; place-items: center; min-height: 40px; border-radius: 9px;
  background: #facc15; color: #111827; font-size: 18px; font-weight: 850;
}
.direction { font-weight: 650; font-size: 14px; }
.meta { color: #94a3b8; font-size: 11px; margin-top: 4px; }
.departure-time { text-align: right; font-size: 19px; font-weight: 800; white-space: nowrap; }
.remaining { color: #38bdf8; font-size: 11px; text-align: right; margin-top: 3px; }
#map {
  height: 340px; width: 100%; border-radius: 14px; border: 1px solid #34445c;
  overflow: hidden; background: #172338;
}
.favorites-list { display: grid; gap: 8px; }
.favorite-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 13px; border-radius: 11px; background: #172338; border: 1px solid #26354b;
}
.favorite-open { flex: 1; border: 0; text-align: left; background: transparent; color: white; }
.favorite-open strong { display: inline; }
.favorite-open small { display: inline; color: #94a3b8; margin-left: 6px; }
.favorite-remove { background: transparent; border: 0; color: #f87171; font-size: 20px; }
.empty, .message { color: #94a3b8; font-size: 13px; padding: 12px 2px; }
footer { text-align: center; color: #64748b; font-size: 11px; padding: 25px 12px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #172338; color: white; }
.leaflet-container a { color: #38bdf8; }
@media (min-width: 700px) {
  main { padding-top: 28px; }
  #map { height: 430px; }
}

/* TABLICA ODJAZDÓW – styl zbliżony do panelu HA */
.departures-section {
  margin-top: 22px;
}

.departures-section .section-heading {
  padding: 0 2px 9px;
  border-bottom: 1px solid #26364b;
}

.departures-section h2 {
  color: #aebbd0;
  font-family: monospace;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.departures-list {
  display: block;
  padding: 4px 9px;
  background: #05080e;
  border: 1px solid #26364b;
  border-radius: 3px;
}

.departure {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 48px;
  align-items: center;
  gap: 7px;
  min-height: 37px;
  padding: 3px 2px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #253044;
  border-radius: 0;
}

.departure:last-child {
  border-bottom: 0;
}

.departure .line {
  display: block;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: #00ed83;
  font-family: monospace;
  font-size: 21px;
  font-weight: 900;
  text-align: left;
  text-shadow: 0 0 5px #00ed83, 0 0 11px #00a85b;
}

.departure .direction {
  min-width: 0;
  overflow: hidden;
  color: #e2e8f0;
  font-family: monospace;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.departure .remaining {
  font-family: monospace;
  font-size: 16px;
  font-weight: 900;
  white-space: nowrap;
  text-align: right;
}

.departure .remaining.urgent {
  color: #ff3434;
  text-shadow: 0 0 5px #ff2525, 0 0 10px #a90000;
}

.departure .remaining.soon {
  color: #168cff;
  text-shadow: 0 0 5px #168cff, 0 0 10px #0055bb;
}

.departure .remaining.later {
  color: #c044ff;
  text-shadow: 0 0 5px #c044ff, 0 0 10px #7800bb;
}

.departure .departure-time {
  color: #ffd34e;
  font-family: monospace;
  font-size: 10px;
  font-weight: 700;
  text-align: right;
}

@media (max-width: 420px) {
  .departure {
    grid-template-columns: 34px minmax(0, 1fr) auto 43px;
    gap: 5px;
  }
  .departure .direction {
    font-size: 11px;
  }
  .departure .remaining {
    font-size: 14px;
  }
}


/* Ikony transportu na mapie */
.map-heading {
  justify-content: space-between;
  flex-wrap: wrap;
}

.location-button {
  font-size: 12px;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.location-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.transport-marker,
.metro-marker {
  background: transparent;
  border: 0;
}

.transport-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 36px;
  height: 24px;
}

.transport-square {
  width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 1px 4px #0008;
}

.bus-square {
  background: #2563eb;
}

.tram-square {
  background: #dc2626;
}

.other-square {
  background: #475569;
}

.metro-pin {
  width: 20px;
  height: 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #dc2626;
  color: white;
  border: 2px solid white;
  box-shadow: 0 2px 7px #0009;
  line-height: 1;
  gap: 0;
}

.metro-pin small {
  font-size: 7px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

/* Klikalny numer linii na tablicy odjazdów */
.departure .line-button {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.departure .line-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.departure .line-button:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 3px;
  border-radius: 3px;
}

/* Nazwa i numer przystanku zawsze w jednym wierszu */
.stop-title {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.stop-title h1 {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.stop-title .stop-number {
  white-space: nowrap;
  flex: 0 0 auto;
}


/* Kompaktowy dymek nazwy przystanku */
.stop-label-popup .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 7px;
}

.stop-label-popup .leaflet-popup-content {
  margin: 5px 9px;
  line-height: 1.2;
  white-space: nowrap;
  font-size: 13px;
}

.stop-label-popup .leaflet-popup-tip-container {
  margin-top: -1px;
}


/* Uproszczony górny pasek */
.topbar {
  justify-content: flex-start;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  font-size: 16px;
  letter-spacing: 1.5px;
}

/* Lokalizacja obok ulubionych */
.stop-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.location-button {
  width: 62px;
  height: 48px;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid #475569;
  border-radius: 12px;
  background: #172338;
  color: #dbeafe;
}

.location-symbol {
  font-size: 22px;
  line-height: 22px;
}

.location-caption {
  font-size: 9px;
  line-height: 11px;
  white-space: nowrap;
}

.location-button:disabled {
  opacity: 0.7;
}


/* Przycisk lokalizacji widoczny przed wyborem przystanku */
.map-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}


/* Przystanki na wyświetlonej trasie */
.route-stop-tooltip {
  background: #172338;
  color: #ffffff;
  border: 1px solid #64748b;
  border-radius: 4px;
  box-shadow: 0 1px 4px #0008;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 5px;
}
.route-stop-tooltip::before {
  border-top-color: #172338;
}
