:root {
  color-scheme: light dark;
  --font: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-muted: rgba(240, 240, 240, 0.94);
  --panel-solid: #ffffff;
  --text: #18212b;
  --muted: #5f6b77;
  --border: rgba(24, 33, 43, 0.15);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  --accent: #dc2626;
}

* { box-sizing: border-box; }

/* Znaczniki na mapie (A/B, ulubione, eksploracja) muszą zostać pod
   panelami UI, nie nad nimi. Sam kontener mapy trzeba przypiąć do
   niskiego z-index, bo inaczej wszystko wewnątrz niego (łącznie ze
   znacznikami) tworzy własny kontekst nakładania, w którym z-index
   pojedynczych elementów wewnątrz nie ma już znaczenia względem
   paneli na zewnątrz. */
#map {
  position: relative;
  z-index: 0;
}

.maplibregl-marker {
  z-index: 2 !important;
}

html, body, #app, #map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
}

button, input, select {
  font: inherit;
}

.toolbar {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: auto minmax(220px, 560px) auto;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

.toolbar > * {
  pointer-events: auto;
}

.brand,
.search,
.toolbar-actions,
.select-wrap,
.icon-button {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  gap: 2px;
  align-items: center;
  min-height: 46px;
  padding: 8px 13px;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: var(--panel);
}

.search {
  display: flex;
  min-height: 46px;
  overflow: hidden;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  outline: none;
}

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.search button {
  border: 0;
  border-left: 1px solid var(--border);
  padding: 0 16px;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

#search-button {
  padding: 0;
  width: 52px;
  min-width: 52px;
  flex: 0 0 52px !important;
  display: grid;
  place-items: center;
}

.toolbar-actions {
  display: flex;
  gap: 6px;
  min-height: 46px;
  padding: 5px;
}

.select-wrap {
  display: flex;
  box-shadow: none;
}

select,
.icon-button {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

select {
  padding: 0 30px 0 10px;
}

.icon-button {
  min-width: 38px;
  font-weight: 800;
  box-shadow: none;
}

.icon-button:hover,
.search button:hover,
select:hover {
  background: rgba(127, 127, 127, 0.12);
}

.status {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  max-width: min(90vw, 560px);
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: center;
}

.maplibregl-ctrl-bottom-right {
  bottom: 8px;
  right: 8px;
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px !important;
  box-shadow: var(--shadow) !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.ui-dark {
  --panel: rgba(27, 31, 38, 0.94);
  --panel-muted: rgba(20, 23, 29, 0.94);
  --panel-solid: #1b1f26;
  --text: #f2f5f8;
  --muted: #b7c0ca;
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  --accent: #f87171;
}

@media (max-width: 820px) {
  .toolbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
    width: 48px;
    min-height: 46px;
    padding: 2px 7px;
    justify-content: center;
  }

  .brand strong {
    display: none;
  }

  .brand-logo {
    width: 31px;
    height: 40px;
  }

  .search {
    grid-column: 2;
    grid-row: 1;
  }

  .toolbar-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: end;
  }
}

@media (max-width: 480px) {
  .toolbar {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 7px;
  }

  .brand {
    width: 44px;
    padding-inline: 5px;
  }

  .brand-logo {
    width: 29px;
    height: 38px;
  }

  .search button {
    padding: 0 12px;
  }

  select {
    max-width: 112px;
  }
}


.fatal-error {
  position: absolute;
  z-index: 20;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 560px);
  padding: 24px;
  background: rgba(255,255,255,.97);
  color: #18212b;
  box-shadow: 0 16px 50px rgba(0,0,0,.28);
}
.fatal-error h1 { margin: 0 0 10px; font-size: 1.25rem; }
.fatal-error p { margin: 8px 0 0; line-height: 1.5; }


.brand-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: block;
}

.brand-mark {
  display: none;
}


.legend-panel {
  position: absolute;
  z-index: 7;
  top: 70px;
  right: 12px;
  width: min(330px, calc(100vw - 24px));
  max-height: calc(100vh - 94px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--text);
  backdrop-filter: blur(12px);
}

.legend-panel[hidden] {
  display: none;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.legend-header h2 {
  margin: 0;
  font-size: 1rem;
}

.legend-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.legend-close:hover {
  background: rgba(127, 127, 127, 0.12);
}

.legend-section + .legend-section {
  margin-top: 17px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.legend-section h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.legend-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend-list li {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 11px;
  align-items: center;
  min-height: 23px;
  color: var(--text);
  font-size: 0.88rem;
}

.legend-symbol {
  position: relative;
  display: block;
  width: 36px;
  height: 18px;
  overflow: hidden;
}

.legend-symbol.liberty-boundary-country::after,
.legend-symbol.liberty-boundary-admin::after,
.legend-symbol.liberty-boundary-disputed::after,
.legend-symbol.liberty-motorway::after,
.legend-symbol.liberty-primary::after,
.legend-symbol.liberty-secondary::after,
.legend-symbol.liberty-minor::after,
.legend-symbol.liberty-path::after,
.legend-symbol.liberty-rail::after,
.legend-symbol.liberty-runway::after,
.legend-symbol.liberty-taxiway::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 1px;
  right: 1px;
  transform: translateY(-50%);
}

.legend-symbol.liberty-boundary-country::after {
  border-top: 3px solid hsl(248, 1%, 41%);
}

.legend-symbol.liberty-boundary-admin::after {
  border-top: 2px dashed hsl(0, 0%, 70%);
}

.legend-symbol.liberty-boundary-disputed::after {
  border-top: 2px dashed hsl(248, 1%, 41%);
}

.legend-symbol.liberty-motorway::after {
  border-top: 6px solid #ffcc88;
  box-shadow: 0 0 0 1px #e9ac77;
}

.legend-symbol.liberty-primary::after {
  border-top: 6px solid #ffeeaa;
  box-shadow: 0 0 0 1px #e9ac77;
}

.legend-symbol.liberty-secondary::after {
  border-top: 4px solid #ffeeaa;
  box-shadow: 0 0 0 1px #e9ac77;
}

.legend-symbol.liberty-minor::after {
  border-top: 4px solid #ffffff;
  box-shadow: 0 0 0 1px #cfcdca;
}

.legend-symbol.liberty-path::after {
  border-top: 2px dashed #ffffff;
  filter: drop-shadow(0 0 1px #9d9d9d);
}

.legend-symbol.liberty-rail::after {
  height: 6px;
  border-top: 2px solid #bbbbbb;
  border-bottom: 2px solid #bbbbbb;
  background: repeating-linear-gradient(
    90deg,
    #bbbbbb 0 2px,
    transparent 2px 6px
  );
}

.legend-symbol.liberty-runway::after {
  border-top: 8px solid #f0ede9;
  box-shadow: 0 0 0 1px #d5d2cf;
}

.legend-symbol.liberty-taxiway::after {
  border-top: 4px solid #f0ede9;
  box-shadow: 0 0 0 1px #d5d2cf;
}

.legend-symbol.liberty-water {
  background: rgb(158, 189, 255);
  border: 1px solid #89a9e9;
}

.legend-symbol.liberty-park {
  background: rgba(216, 232, 200, 0.7);
  border: 1px solid rgba(95, 208, 100, 1);
}

.legend-symbol.liberty-wood {
  background: hsla(98, 61%, 72%, 0.4);
  border: 1px solid hsla(98, 42%, 55%, 0.6);
}

.legend-symbol.liberty-grass {
  background: rgba(176, 213, 154, 0.3);
  border: 1px solid rgba(145, 185, 123, 0.55);
}

.legend-symbol.liberty-wetland {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(90, 150, 135, 0.55) 0 1px,
      transparent 1px 5px
    ),
    #d9ebe4;
  border: 1px solid #a8c9bf;
}

.legend-symbol.liberty-sand {
  background: rgba(247, 239, 195, 1);
  border: 1px solid #ded3a4;
}

.legend-symbol.liberty-residential {
  background: hsla(0, 3%, 85%, 0.84);
  border: 1px solid hsla(35, 20%, 72%, 0.65);
}

.legend-symbol.liberty-cemetery {
  background: hsl(75, 37%, 81%);
  border: 1px solid hsl(75, 27%, 67%);
}

.legend-symbol.liberty-hospital {
  background: #ffddee;
  border: 1px solid #e7b8d0;
}

.legend-symbol.liberty-school {
  background: rgb(236, 238, 204);
  border: 1px solid #d1d4aa;
}

.legend-symbol.liberty-building {
  background: hsl(35, 8%, 85%);
  border: 1px solid hsl(35, 6%, 79%);
}

body.ui-dark .legend-symbol {
  filter: brightness(0.78) saturate(0.78);
}

body.ui-dark .legend-symbol.liberty-minor::after,
body.ui-dark .legend-symbol.liberty-path::after {
  border-top-color: #cfd5da;
}

.legend-note {
  margin: 16px 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

body.ui-dark .legend-symbol.osm-local::after {
  border-top-color: #e8ecef;
  box-shadow: 0 0 0 1px #747d84;
}

body.ui-dark .legend-symbol.osm-water {
  filter: brightness(0.72) saturate(0.8);
}

body.ui-dark .legend-symbol.osm-forest,
body.ui-dark .legend-symbol.osm-park,
body.ui-dark .legend-symbol.osm-farmland,
body.ui-dark .legend-symbol.osm-residential,
body.ui-dark .legend-symbol.osm-industrial,
body.ui-dark .legend-symbol.osm-buildings {
  filter: brightness(0.72) saturate(0.75);
}

@media (max-width: 820px) {
  .legend-panel {
    top: 126px;
  }
}

@media (max-width: 480px) {
  .legend-panel {
    top: 122px;
    right: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 138px);
  }
}


/* Ikona informacji w przycisku legendy */
#legend-button{
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 1.15rem;
}


.svg-icon-button {
  display: grid;
  place-items: center;
  padding: 0;
}

.svg-icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.about-panel,
.backup-panel {
  width: min(390px, calc(100vw - 24px));
}

.about-content {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.62;
}

.about-content p {
  margin: 0 0 14px;
}

.about-content h3 {
  margin: 20px 0 9px;
  font-size: 1rem;
  line-height: 1.35;
}

.about-draft-note {
  padding: 11px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(127, 127, 127, 0.09);
  color: var(--muted);
  font-style: italic;
}

.about-meta {
  display: grid;
  gap: 11px;
  margin: 18px 0 0;
  padding: 15px 0 0;
  border-top: 1px solid var(--border);
}

.about-meta div {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
}

.about-meta dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.about-meta dd {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
}

.about-contact {
  margin: 16px 0 0;
  font-size: 0.82rem;
  color: var(--text);
}

.about-contact a {
  color: var(--accent);
}

.about-github {
  margin: 10px 0 0;
  font-size: 0.82rem;
}

.about-github a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  text-decoration: none;
}

.about-github a:hover {
  text-decoration: underline;
}

.about-github svg {
  flex: 0 0 auto;
}

.about-donate {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.about-donate-heading {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.about-donate-coffee {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
}

.about-donate-coffee:hover,
.about-donate-coffee:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.about-donate-btc {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.about-donate-btc:hover,
.about-donate-btc:focus-visible {
  border-color: var(--accent);
}

.about-donate-btc-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.about-donate-btc code {
  font-size: 0.68rem;
  color: var(--muted);
  word-break: break-all;
}

@media (max-width: 480px) {
  .about-panel,
  .backup-panel {
    width: calc(100vw - 16px);
  }

  .about-meta div {
    grid-template-columns: 100px 1fr;
  }
}


.route-panel {
  width: min(390px, calc(100vw - 24px));
}

.route-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 8px;
  align-items: end;
}

.route-form label {
  display: grid;
  gap: 6px;
  grid-column: 1;
}

.route-form label span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.route-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  padding: 0 11px;
  background: rgba(127, 127, 127, 0.07);
  color: var(--text);
  outline: none;
}

.route-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.route-swap {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
}

.route-swap:hover,
.route-secondary:hover {
  background: rgba(127, 127, 127, 0.11);
}

.route-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 3px;
}

.route-primary,
.route-secondary {
  min-height: 40px;
  padding: 0 13px;
  font-weight: 750;
  cursor: pointer;
}

.route-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--panel);
}

.route-secondary {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}

.route-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 15px;
}

.route-summary > div {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  background: rgba(127, 127, 127, 0.07);
}

.route-summary strong {
  font-size: 1.03rem;
}

.route-summary span {
  color: var(--muted);
  font-size: 0.74rem;
}

.route-note {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

@media (max-width: 480px) {
  .route-panel {
    width: calc(100vw - 16px);
  }
}


.search #route-button {
  min-width: 44px;
  border-left: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.search #route-button:hover {
  background: rgba(127, 127, 127, 0.12);
}


.route-modes {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 0 0 3px;
  padding: 0;
  border: 0;
}

.route-modes legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.route-modes label {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  align-items: center;
  min-height: 52px;
  padding: 0 9px;
  border: 1px solid var(--border);
  background: rgba(127, 127, 127, 0.06);
  color: var(--text);
  font-size: 0.78rem;
  cursor: pointer;
}

.route-modes input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.route-modes label:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  box-shadow: 0 0 0 1px var(--accent);
}

.route-modes label:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 370px) {
  .route-modes label {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 1px;
    padding: 5px 3px;
  }
}


/* Kompaktowy wybór środka transportu */
.route-modes{
  display:flex !important;
  gap:8px;
  align-items:center;
}

.route-modes legend{
  width:100%;
  flex-basis:100%;
}

.route-modes label{
  flex:1;
  display:flex !important;
  justify-content:center;
  align-items:center;
  min-height:42px;
  padding:0;
}

.route-mode-emoji{
  font-size:1.9rem;
  line-height:1;
}


/* Pola A/B z przyciskiem zamiany po prawej, wyśrodkowanym między nimi */
.route-form {
  display: block;
}

.route-points {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  grid-template-rows: auto auto;
  gap: 10px 9px;
  align-items: center;
}

.route-point {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.route-point-from {
  grid-column: 1;
  grid-row: 1;
}

.route-point-to {
  grid-column: 1;
  grid-row: 2;
}

.route-swap {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  justify-self: center;
  width: 36px;
  height: 36px;
  margin-top: 12px;
}

.route-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 13px;
}

.route-primary {
  width: 100%;
}

@media (max-width: 360px) {
  .route-points {
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 9px 6px;
  }

  .route-swap {
    width: 34px;
    height: 34px;
  }
}


.route-click-hint {
  margin: 0 0 13px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(127, 127, 127, 0.09);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.4;
}

.route-click-hint.is-complete {
  color: var(--muted);
  border-left-color: var(--muted);
}

.map-picking-route .maplibregl-canvas {
  cursor: crosshair;
}

.route-letter-marker {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 3px solid #ffffff;
  color: #ffffff;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 850;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.34);
  transform: rotate(-45deg);
}

.route-letter-marker > span {
  transform: rotate(45deg);
}

.route-letter-marker.route-a {
  background: #16a34a;
}

.route-letter-marker.route-b {
  background: #dc2626;
}


/* Większe ikony środków transportu */
.route-mode-emoji{
  font-size:2.4rem !important;
  line-height:1;
}

.route-modes label{
  min-height:60px !important;
}




/* Mobilny panel Trasa jako przeciągany bottom sheet */
.route-sheet-handle {
  display: none;
}

@media (max-width: 600px) {
  .route-panel {
    --route-sheet-height: 42vh;
    position: absolute;
    top: auto !important;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto !important;
    height: var(--route-sheet-height);
    max-height: calc(100vh - 16px) !important;
    min-height: 180px;
    padding: 0 14px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    transition: height 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .route-panel.is-dragging {
    transition: none;
    user-select: none;
  }

  .route-sheet-handle {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 100%;
    height: 28px;
    margin: 0;
    border: 0;
    background: var(--panel);
    cursor: grab;
    touch-action: none;
  }

  .route-sheet-handle:active {
    cursor: grabbing;
  }

  .route-sheet-handle span {
    display: block;
    width: 44px;
    height: 5px;
    background: color-mix(in srgb, var(--text) 35%, transparent);
  }

  .route-panel .legend-header {
    position: sticky;
    top: 28px;
    z-index: 3;
    margin: 0 -14px 12px;
    padding: 9px 14px 10px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }

  .route-click-hint {
    display: none;
  }

  .route-modes label {
    min-height: 52px !important;
  }

  .route-mode-emoji {
    font-size: 2.25rem !important;
  }

  .route-points {
    gap: 8px 7px;
  }

  .route-form input {
    min-height: 39px;
  }

  .route-actions {
    margin-top: 10px;
  }

  .route-summary {
    margin-top: 11px;
  }

  .route-note {
    margin-top: 10px;
  }

  body:has(.route-panel:not([hidden])) .maplibregl-ctrl-bottom-right,
  body:has(.route-panel:not([hidden])) .maplibregl-ctrl-bottom-left {
    bottom: calc(var(--route-sheet-height, 42vh) + 18px);
  }
}

@media (max-width: 390px), (max-height: 700px) {
  .route-panel {
    min-height: 160px;
  }

  .route-mode-emoji {
    font-size: 2.05rem !important;
  }

  .route-modes label {
    min-height: 47px !important;
  }

  .route-note {
    display: none;
  }
}


/* Płynny bottom sheet: treść znika po pełnym zwinięciu */
@media (max-width: 600px) {
  .route-panel {
    min-height: 48px;
  }

  .route-panel.is-collapsed {
    padding-bottom: 0;
    overflow: hidden;
  }

  .route-panel.is-collapsed .legend-header,
  .route-panel.is-collapsed .route-click-hint,
  .route-panel.is-collapsed .route-form,
  .route-panel.is-collapsed .route-summary,
  .route-panel.is-collapsed .route-note {
    display: none;
  }

  .route-panel.is-collapsed .route-sheet-handle {
    height: 48px;
  }

  .route-panel.is-collapsed .route-sheet-handle span {
    width: 52px;
  }
}


.route-directions {
  margin-top: 15px;
  border-top: 1px solid var(--border);
  padding-top: 13px;
}

.route-directions[hidden] {
  display: none;
}

.route-directions-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.route-directions-header h3 {
  margin: 0;
  font-size: 0.92rem;
}

.route-directions-count {
  color: var(--muted);
  font-size: 0.72rem;
}

.route-directions-list {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: route-step;
}

.route-direction {
  counter-increment: route-step;
}

.route-direction-button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  border: 0;
  padding: 7px 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.route-direction-button:hover,
.route-direction-button:focus-visible {
  background: rgba(127, 127, 127, 0.11);
}

.route-direction-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: rgba(127, 127, 127, 0.07);
  font-size: 1.2rem;
  line-height: 1;
}

.route-direction-copy {
  min-width: 0;
}

.route-direction-instruction {
  display: block;
  font-size: 0.83rem;
  line-height: 1.35;
}

.route-direction-street {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-direction-distance {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.route-direction:first-child .route-direction-icon {
  border-color: #16a34a;
}

.route-direction:last-child .route-direction-icon {
  border-color: #dc2626;
}

@media (max-width: 600px) {
  .route-directions {
    margin-top: 12px;
  }

  .route-direction-button {
    min-height: 49px;
  }
}


.route-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.route-share {
  width: 100%;
  min-height: 40px;
  margin-top: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
}

.route-share:hover {
  background: rgba(127, 127, 127, 0.11);
}

.route-waypoint-note {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
}

.route-direction-button.is-selected {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.route-waypoint-marker {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 3px solid #fff;
  background: #7c3aed;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 850;
  box-shadow: 0 3px 10px rgba(0,0,0,.34);
  cursor: grab;
}

.route-waypoint-marker:active {
  cursor: grabbing;
}

@media (max-width: 420px) {
  .route-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .route-summary > div {
    padding: 9px 7px;
  }

  .route-summary strong {
    font-size: .9rem;
  }
}




.autocomplete-list {
  position: fixed;
  z-index: 1000;
  max-height: 260px;
  margin: 0;
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  list-style: none;
}

.autocomplete-list[hidden] {
  display: none;
}

.autocomplete-floating {
  min-width: 220px;
}

.autocomplete-option {
  width: 100%;
  border: 0;
  padding: 9px 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.autocomplete-option:hover,
.autocomplete-option:focus-visible,
.autocomplete-option.is-active {
  background: rgba(127, 127, 127, 0.12);
}

.autocomplete-option strong {
  display: block;
  overflow: hidden;
  font-size: 0.84rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-option span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .autocomplete-list {
    max-height: 190px;
  }
}


.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 28px;
  margin: 0 8px 0 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-1px);
  flex: 0 0 auto;
}

.search-clear:hover,
.search-clear:focus-visible {
  background: transparent;
  color: var(--text);
}

.search-clear[hidden] {
  display: none;
}

.route-letter-marker {
  cursor: grab;
}

.route-letter-marker:active {
  cursor: grabbing;
}


/* Usuń separator przed przyciskiem czyszczenia */
.search-clear::before{
  content:none !important;
}

.search > .search-clear{
  border-left:none !important;
  box-shadow:none !important;
}


.autocomplete-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.autocomplete-history-clear {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.autocomplete-history-clear:hover,
.autocomplete-history-clear:focus-visible {
  color: var(--text);
}

.autocomplete-history-option {
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
}

.autocomplete-history-icon {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1rem;
}

.autocomplete-history-copy {
  min-width: 0;
}


.maplibregl-popup-content {
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.maplibregl-popup-close-button {
  z-index: 2;
  width: 32px;
  height: 32px;
  color: var(--muted);
  font-size: 1.25rem;
}

.place-card {
  width: min(340px, calc(100vw - 48px));
  overflow: hidden;
}

.place-card-loading {
  padding: 16px;
  color: var(--muted);
  font-size: 0.84rem;
}

.place-card-image {
  display: block;
  width: 100%;
  height: 145px;
  object-fit: cover;
  background: rgba(127, 127, 127, 0.08);
}

.place-card-heading {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 15px 16px 10px;
}

.place-card-type-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: rgba(127, 127, 127, 0.07);
  font-size: 1.45rem;
}

.place-card-heading-copy {
  min-width: 0;
}

.place-card-title {
  margin: 0;
  padding-right: 24px;
  font-size: 1rem;
  line-height: 1.3;
}

.place-card-type {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.place-card-details {
  display: grid;
  gap: 3px;
  padding: 0 10px 8px;
}

.place-card-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  width: 100%;
  min-height: 38px;
  border: 0;
  padding: 6px 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
}

.place-card-row-interactive {
  cursor: pointer;
}

.place-card-row-interactive:hover,
.place-card-row-interactive:focus-visible,
.place-card-row.is-copied {
  background: rgba(127, 127, 127, 0.11);
}

.place-card-row-icon {
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.place-card-row-value {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
  line-height: 1.35;
}

.place-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 11px 16px 16px;
  border-top: 1px solid var(--border);
}

.place-card-action {
  display: grid;
  place-items: center;
  min-height: 39px;
  border: 1px solid var(--border);
  padding: 6px 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.place-card-action:hover,
.place-card-action:focus-visible {
  background: rgba(127, 127, 127, 0.11);
}

.place-card-link {
  grid-column: 1 / -1;
}

@media (max-width: 480px) {
  .place-card {
    width: min(310px, calc(100vw - 34px));
  }

  .place-card-image {
    height: 125px;
  }

  .place-card-heading {
    padding: 13px 14px 9px;
  }

  .place-card-actions {
    grid-template-columns: 1fr;
    padding: 10px 14px 14px;
  }

  .place-card-link {
    grid-column: auto;
  }
}


/* Pełna szerokość przycisku Udostępnij w karcie miejsca */
.place-card-actions > .place-card-action:nth-child(3) {
  grid-column: 1 / -1;
}


.place-departures {
  margin: 4px 10px 0;
  padding: 12px 6px 6px;
  border-top: 1px solid var(--border);
}

.place-departures-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px 8px;
}

.place-departures-header h4 {
  margin: 0;
  font-size: 0.84rem;
}

.place-departures-status {
  margin: 0;
  padding: 7px 6px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
}

.place-departures-list {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.place-departure {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 48px;
  padding: 6px;
}

.place-departure:hover {
  background: rgba(127, 127, 127, 0.08);
}

.place-departure.is-cancelled {
  opacity: 0.58;
  text-decoration: line-through;
}

.place-departure.is-clickable {
  cursor: pointer;
}

.place-departure.is-clickable:hover,
.place-departure.is-clickable:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  outline: none;
}

.trip-panel-content {
  padding: 4px 14px 14px;
}

.trip-status {
  padding: 14px 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.trip-stops-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.trip-stop {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  min-height: 38px;
  padding: 6px;
  border-left: 2px solid var(--border);
  margin-left: 6px;
  padding-left: 12px;
}

.trip-stop-time {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.trip-stop-name {
  font-size: 0.88rem;
  font-weight: 650;
}

.trip-stop:first-child,
.trip-stop:last-child {
  border-left-color: var(--accent);
}

.trip-stop.is-current-stop {
  grid-template-columns: 60px minmax(0, 1fr) auto;
  border-left-color: var(--accent);
  border-left-width: 4px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.trip-stop.is-current-stop .trip-stop-name {
  color: var(--accent);
  font-weight: 800;
}

.trip-stop.is-clickable {
  cursor: pointer;
}

.trip-stop.is-clickable:hover,
.trip-stop.is-clickable:focus-visible {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  outline: none;
}

.trip-stop-badge {
  padding: 3px 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--panel-solid);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  align-self: center;
}

.place-wikipedia {
  margin: 4px 10px 0;
  padding: 12px 6px 6px;
  border-top: 1px solid var(--border);
}

.place-wikipedia-header {
  padding: 0 6px 8px;
}

.place-wikipedia-header h4 {
  margin: 0;
  font-size: 0.84rem;
}

.place-wikipedia-thumbnail {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  margin: 0 0 8px;
  border: 1px solid var(--border);
}

.place-wikipedia-extract {
  margin: 0 6px 8px;
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.5;
}

.place-wikipedia-link {
  display: block;
  margin: 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: none;
}

.place-wikipedia-link:hover {
  text-decoration: underline;
}

.place-departure-line {
  display: grid;
  place-items: center;
  min-width: 42px;
  min-height: 28px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  background: rgba(127, 127, 127, 0.08);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1;
}

.place-departure-copy {
  min-width: 0;
}

.place-departure-direction {
  display: block;
  overflow: hidden;
  font-size: 0.78rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-departure-time {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.3;
}

.place-departures-source {
  display: inline-block;
  margin: 7px 6px 0;
  color: var(--muted);
  font-size: 0.66rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 480px) {
  .place-departures {
    margin-inline: 8px;
  }

  .place-departure {
    grid-template-columns: 44px minmax(0, 1fr);
  }
}


.place-departures-list.is-expanded {
  max-height: 245px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.place-departures-toggle {
  display: block;
  width: calc(100% - 12px);
  min-height: 34px;
  margin: 7px 6px 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 750;
  cursor: pointer;
}

.place-departures-toggle:hover,
.place-departures-toggle:focus-visible {
  background: rgba(127, 127, 127, 0.1);
}

.place-departures-toggle[hidden] {
  display: none;
}

@media (max-width: 480px) {
  .place-departures-list.is-expanded {
    max-height: 205px;
  }
}


.autocomplete-option {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.autocomplete-place-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: rgba(127, 127, 127, 0.08);
  font-size: 1.05rem;
}

.autocomplete-place-copy {
  min-width: 0;
}

.autocomplete-place-copy strong,
.autocomplete-place-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-place-copy strong {
  font-size: 0.84rem;
  line-height: 1.35;
}

.autocomplete-place-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.3;
}


/* Czerwony, kanciasty język wizualny interfejsu */
.brand,
.search,
.toolbar-actions,
.select-wrap,
.icon-button,
select,
.status,
.maplibregl-ctrl-group,
.legend-panel,
.route-panel,
.about-panel,
.backup-panel,
.legend-close,
.route-primary,
.route-secondary,
.route-share,
.route-swap,
.route-modes label,
.route-form input,
.autocomplete-list,
.autocomplete-option,
.autocomplete-place-icon,
.autocomplete-history-clear,
.place-card,
.place-card-type-icon,
.place-card-row,
.place-card-action,
.place-departures-toggle,
.place-departure,
.place-departure-line,
.route-direction-button,
.route-direction-icon {
  border-radius: 0 !important;
}

button,
select,
input,
a.place-card-action,
a.place-card-row {
  border-radius: 0 !important;
}

.maplibregl-popup-content {
  border-radius: 0 !important;
}

.search button,
.icon-button,
.legend-close,
.route-primary,
.route-share,
.place-card-action,
.place-card-row-interactive,
.autocomplete-option,
.place-departures-toggle {
  color: var(--accent);
}

.search button:hover,
.icon-button:hover,
.legend-close:hover,
.route-primary:hover,
.route-share:hover,
.place-card-action:hover,
.place-card-row-interactive:hover,
.autocomplete-option:hover,
.place-departures-toggle:hover {
  color: var(--accent);
}


/* Przywrócony, czytelny przycisk wyznaczania trasy */
.route-primary,
.route-primary:hover,
.route-primary:focus-visible {
  background: var(--accent) !important;
  color: var(--panel) !important;
  border-color: var(--accent) !important;
  font-size: 0.86rem;
  text-indent: 0;
}

/* Cztery zwarte tryby podróży */
.route-modes label {
  display: grid;
  place-items: center;
  grid-template-columns: 1fr;
  padding-inline: 5px;
}

@media (max-width: 420px) {
  .route-modes {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .route-mode-emoji {
    font-size: 1.8rem !important;
  }
}


/* Flagi w przełączniku języka */
#language-select {
  min-width: 52px;
  font-size: 1.1rem;
  text-align: center;
}

/* Markery trybu eksploracji */
.explore-marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 0;
  background: var(--accent);
  color: var(--panel);
  font-size: 1.05rem;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.32);
  cursor: pointer;
}

.explore-marker:hover,
.explore-marker:focus-visible {
  transform: scale(1.08);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


.discover-panel {
  width: min(360px, calc(100vw - 24px));
}

.discover-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.discover-categories {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 2px;
}

.discover-category-group-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.discover-category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.discover-categories button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.discover-categories button:hover,
.discover-categories button:focus-visible,
.discover-categories button.is-active {
  border-color: var(--accent);
  background: color-mix(
    in srgb,
    var(--accent) 12%,
    transparent
  );
}

.discover-category-emoji,
.discover-categories button {
  font-size: 1.05rem;
}

.discover-categories button span {
  font-size: 0.76rem;
  font-weight: 750;
}

.discover-status {
  margin-top: 12px;
  padding: 9px 10px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
}

.discover-clear {
  width: 100%;
  min-height: 38px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 750;
  cursor: pointer;
}

.discover-clear:hover,
.discover-clear:focus-visible {
  border-color: var(--accent);
  background: color-mix(
    in srgb,
    var(--accent) 10%,
    transparent
  );
}

.discover-clear[hidden] {
  display: none;
}

.discover-button span {
  font-size: 1rem;
}

@media (max-width: 600px) {
  .discover-panel {
    position: absolute;
    top: auto !important;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: 62vh;
    overflow-y: auto;
  }
}

@media (max-width: 390px) {
  .discover-categories {
    gap: 6px;
  }

  .discover-category-grid {
    gap: 6px;
  }

  .discover-categories button {
    min-height: 44px;
    padding-inline: 8px;
  }
}




.menu-panel {
  width: min(280px, calc(100vw - 24px));
}

.menu-actions {
  display: grid;
  gap: 8px;
}

.menu-action {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.menu-action:hover,
.menu-action:focus-visible {
  border-color: var(--accent);
  background: color-mix(
    in srgb,
    var(--accent) 10%,
    transparent
  );
}

.menu-action > span:first-child {
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.menu-action > span:last-child {
  font-size: 0.78rem;
  font-weight: 750;
}

#menu-button {
  margin-left: 6px;
}

#about-button {
  margin-left: 8px;
}

@media (max-width: 600px) {
  .menu-panel {
    right: 8px;
    left: auto;
    width: min(280px, calc(100vw - 16px));
  }
}


/* Prawy blok: tylko wygląd mapy i menu */
.toolbar-actions {
  margin-left: auto !important;
  justify-content: flex-end !important;
  flex: 0 0 auto;
}

.legacy-hidden-controls {
  display: none !important;
}

.menu-panel {
  right: 12px !important;
  left: auto !important;
  width: min(310px, calc(100vw - 24px));
}

.menu-actions {
  display: grid;
  gap: 8px;
}

.menu-action,
.menu-setting {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.menu-action {
  cursor: pointer;
}

.menu-action:hover,
.menu-action:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.menu-setting {
  grid-template-columns: 32px minmax(0, 1fr) auto;
}

.menu-setting select {
  min-width: 118px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
  padding: 6px 8px;
}

.menu-custom-palette {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  margin: -2px 0 0;
}

.menu-custom-palette[hidden] {
  display: none;
}

.menu-custom-palette-heading {
  margin: 4px 0 0;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.menu-custom-palette-heading:first-child {
  margin-top: 0;
}

.menu-custom-palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}

.menu-custom-palette-grid label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
}

.menu-custom-palette-grid input[type="color"] {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.menu-custom-palette-grid input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.menu-custom-palette-grid input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

#custom-palette-reset {
  align-self: flex-start;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 12px;
  font-size: 0.7rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

#custom-palette-reset:hover,
#custom-palette-reset:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 600px) {
  .menu-panel {
    right: 8px !important;
    left: auto !important;
    width: min(310px, calc(100vw - 16px));
  }
}


/* Bardziej zwarty kontener logo */
.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  width: fit-content !important;
  max-width: fit-content !important;
  padding: 0 18px 0 14px !important;
  white-space: nowrap;
}






/* Odkrywaj: dokładnie ten sam mobilny bottom sheet co Trasa */
.discover-sheet-handle {
  display: none;
}

@media (max-width: 600px) {
  .discover-panel {
    --discover-sheet-height: 42vh;
    position: absolute;
    top: auto !important;
    right: 8px !important;
    bottom: 8px !important;
    left: 8px !important;
    width: auto !important;
    height: var(--discover-sheet-height);
    max-height: calc(100vh - 16px) !important;
    min-height: 48px;
    padding: 0 14px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    transition: height 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .discover-panel.is-dragging {
    transition: none;
    user-select: none;
  }

  .discover-sheet-handle {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 100%;
    height: 28px;
    margin: 0;
    border: 0;
    background: var(--panel);
    cursor: grab;
    touch-action: none;
  }

  .discover-sheet-handle:active {
    cursor: grabbing;
  }

  .discover-sheet-handle span {
    display: block;
    width: 44px;
    height: 5px;
    background:
      color-mix(in srgb, var(--text) 35%, transparent);
  }

  .discover-panel .legend-header {
    position: sticky;
    top: 28px;
    z-index: 3;
    margin: 0 -14px 12px;
    padding: 9px 14px 10px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }

  .discover-panel.is-collapsed {
    padding-bottom: 0;
    overflow: hidden;
  }

  .discover-panel.is-collapsed .legend-header,
  .discover-panel.is-collapsed .discover-note,
  .discover-panel.is-collapsed .discover-categories,
  .discover-panel.is-collapsed .discover-status,
  .discover-panel.is-collapsed .discover-clear {
    display: none;
  }

  .discover-panel.is-collapsed .discover-sheet-handle {
    height: 48px;
  }

  .discover-panel.is-collapsed .discover-sheet-handle span {
    width: 52px;
  }

  body:has(.discover-panel:not([hidden]))
  .maplibregl-ctrl-bottom-right,
  body:has(.discover-panel:not([hidden]))
  .maplibregl-ctrl-bottom-left {
    bottom: calc(
      var(--discover-sheet-height, 42vh) + 18px
    );
  }
}

/* Menu ma taki sam rozmiar jak przycisk nad nim */
.toolbar-actions {
  width: 56px !important;
  min-width: 56px !important;
  height: 46px;
  min-height: 46px;
  padding: 0 !important;
}

#menu-button {
  width: 100% !important;
  min-width: 56px !important;
  height: 46px !important;
  min-height: 46px !important;
  margin: 0 !important;
  display: grid;
  place-items: center;
}


/* ☰ ma identyczny rozmiar jak przyciski Trasa/Odkrywaj */
.toolbar-actions{
  width:auto !important;
  min-width:0 !important;
  height:auto !important;
  min-height:0 !important;
  padding:0 !important;
  border:none !important;
  box-shadow:none !important;
  background:transparent !important;
}

#menu-button{
  width:46px !important;
  min-width:46px !important;
  height:46px !important;
  min-height:46px !important;
  padding:0 !important;
  margin:0 !important;
  border:1px solid var(--border) !important;
  border-radius:0 !important;
  display:grid !important;
  place-items:center;
  background:var(--panel);
  box-shadow:var(--shadow);
}

#menu-button:hover{
  background:rgba(127,127,127,.12);
}


/* Mobilny dolny pasek głównych funkcji */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 600px) {
  .toolbar {
    grid-template-columns: auto minmax(0, 1fr) !important;
    gap: 8px;
    align-items: stretch;
  }

  .toolbar .brand {
    grid-column: 1;
  }

  .toolbar .search {
    grid-column: 2;
    width: 100%;
  }

  .toolbar .toolbar-actions,
  .toolbar .search #route-button,
  .toolbar .search #discover-button {
    display: none !important;
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 30;
    right: 8px;
    bottom: 8px;
    left: 8px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: 58px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
  }

  .mobile-bottom-action {
    display: grid;
    grid-template-rows: auto auto;
    place-items: center;
    gap: 2px;
    min-width: 0;
    min-height: 58px;
    padding: 5px 8px;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
  }

  .mobile-bottom-action:last-child {
    border-right: 0;
  }

  .mobile-bottom-action > span:first-child {
    font-size: 1.25rem;
    line-height: 1;
  }

  .mobile-bottom-action > span:last-child {
    font-size: 0.68rem;
    font-weight: 750;
  }

  .mobile-bottom-action:hover,
  .mobile-bottom-action:focus-visible,
  .mobile-bottom-action.is-active {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 11%, transparent);
  }

  body {
    padding-bottom: 74px;
  }

  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right {
    bottom: 78px;
  }
}

@media (max-width: 430px) {
  .toolbar {
    grid-template-columns: 1fr !important;
  }

  .toolbar .brand,
  .toolbar .search {
    grid-column: 1;
  }

  .toolbar .brand {
    justify-self: start;
  }
}


/* Na telefonach ukryj kontrolki i atrybucję mapy */
@media (max-width: 600px) {
  .maplibregl-ctrl-top-left,
  .maplibregl-ctrl-top-right,
  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right,
  .maplibregl-ctrl-attrib,
  .maplibregl-ctrl-scale,
  .maplibregl-ctrl-group {
    display: none !important;
  }
}


/* Menu: ten sam mobilny bottom sheet co Trasa i Odkrywaj */
.menu-sheet-handle {
  display: none;
}

@media (max-width: 600px) {
  .menu-panel {
    --menu-sheet-height: 42vh;
    position: absolute;
    top: auto !important;
    right: 8px !important;
    bottom: 74px !important;
    left: 8px !important;
    width: auto !important;
    height: var(--menu-sheet-height);
    max-height: calc(100vh - 90px) !important;
    min-height: 48px;
    padding: 0 14px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    transition: height 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .menu-panel.is-dragging {
    transition: none;
    user-select: none;
  }

  .menu-sheet-handle {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 100%;
    height: 28px;
    margin: 0;
    border: 0;
    background: var(--panel);
    cursor: grab;
    touch-action: none;
  }

  .menu-sheet-handle:active {
    cursor: grabbing;
  }

  .menu-sheet-handle span {
    display: block;
    width: 44px;
    height: 5px;
    background:
      color-mix(in srgb, var(--text) 35%, transparent);
  }

  .menu-panel .legend-header {
    position: sticky;
    top: 28px;
    z-index: 3;
    margin: 0 -14px 12px;
    padding: 9px 14px 10px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }

  .menu-panel.is-collapsed {
    padding-bottom: 0;
    overflow: hidden;
  }

  .menu-panel.is-collapsed .legend-header,
  .menu-panel.is-collapsed .menu-actions {
    display: none;
  }

  .menu-panel.is-collapsed .menu-sheet-handle {
    height: 48px;
  }

  .menu-panel.is-collapsed .menu-sheet-handle span {
    width: 52px;
  }
}


/* Na telefonach skala jest widoczna tylko przy zamkniętych panelach */
@media (max-width: 600px) {
  .maplibregl-ctrl-bottom-left {
    display: block !important;
    bottom: 78px !important;
  }

  .maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale {
    display: block !important;
  }

  .maplibregl-ctrl-bottom-left
  > :not(.maplibregl-ctrl-scale) {
    display: none !important;
  }

  body:has(.route-panel:not([hidden]))
  .maplibregl-ctrl-bottom-left,
  body:has(.discover-panel:not([hidden]))
  .maplibregl-ctrl-bottom-left,
  body:has(.menu-panel:not([hidden]))
  .maplibregl-ctrl-bottom-left {
    display: none !important;
  }
}


/* Telefon: zmniejsz odstęp między skalą a dolnym paskiem */
@media (max-width: 600px) {
  .maplibregl-ctrl-bottom-left {
    bottom: 62px !important;
    margin-bottom: 0 !important;
  }

  .maplibregl-ctrl-scale {
    margin: 0 0 4px 8px !important;
  }
}


/* Telefon: skala niemal bezpośrednio nad dolnym paskiem */
@media (max-width: 600px) {
  .maplibregl-ctrl-bottom-left {
    bottom: 54px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale {
    margin: 0 0 1px 6px !important;
  }
}


/* Ostateczna poprawka mobilnego pustego pasa:
   mapa zawsze zajmuje cały ekran, a dolny pasek leży nad nią. */
@media (max-width: 600px) {
  html,
  body,
  #app,
  #map {
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
  }

  body {
    padding: 0 !important;
  }

  #app,
  #map {
    position: fixed !important;
    inset: 0 !important;
  }

  .mobile-bottom-nav {
    right: 8px !important;
    bottom: 8px !important;
    left: 8px !important;
  }

  .maplibregl-ctrl-bottom-left {
    bottom: 69px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale {
    margin: 0 0 2px 6px !important;
  }
}


/* Mobilny znak logo jako część wyszukiwarki */
.mobile-search-logo {
  display: none;
}

@media (max-width: 600px) {
  .toolbar {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .toolbar > .brand {
    display: none !important;
  }

  .toolbar .search {
    grid-column: 1 !important;
    width: 100%;
  }

  .mobile-search-logo {
    display: grid;
    place-items: center;
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px;
    height: 46px;
    border-right: 1px solid var(--border);
    background: transparent;
    text-decoration: none;
  }

  .mobile-search-logo img {
    display: block;
    width: 30px;
    height: 30px;
    object-fit: contain;
  }

  .search input {
    min-width: 0;
  }
}


/* Zwarte akcje karty miejsca — same emoji */
.place-card-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.place-card-action {
  min-height: 42px;
  padding: 0 !important;
  font-size: 1.25rem !important;
  line-height: 1;
}

.place-card-action.is-favorite {
  color: var(--accent);
}

/* Lista wyników Odkrywaj */
.discover-results-list {
  display: grid;
  gap: 4px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.discover-results-list[hidden] {
  display: none;
}

.discover-result-button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.discover-result-button:hover,
.discover-result-button:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.discover-result-button > span:first-child {
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}

.discover-result-button > span:last-child {
  min-width: 0;
}

.discover-result-button strong,
.discover-result-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discover-result-button strong {
  font-size: 0.76rem;
}

.discover-result-button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.65rem;
}

.route-direction-meta {
  display: block;
  margin-top: 3px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
}

@media (max-width: 600px) {
  .discover-results-list {
    padding-bottom: 12px;
  }
}


/* Wszystkie prostokąty akcji w karcie miejsca mają identyczne wymiary */
.place-card-actions {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 8px !important;
}

.place-card-action {
  width: 100% !important;
  min-width: 0 !important;
  height: 42px !important;
  min-height: 42px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  justify-self: stretch !important;
  box-sizing: border-box !important;
}


/* Ostateczne wyrównanie wszystkich akcji karty miejsca */
.place-card-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

@media (max-width: 480px) {
  .place-card-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

.place-card-actions > .place-card-action,
.place-card-actions > .place-card-action:nth-child(3),
.place-card-actions > .place-card-link {
  grid-column: auto !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 42px !important;
  box-sizing: border-box !important;
}


/* Ulubione jako pierwsza sekcja menu */
.menu-favorites {
  display: grid;
  gap: 6px;
}

.menu-favorites-toggle {
  grid-template-columns: 32px minmax(0, 1fr) auto !important;
}

.favorites-count {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.favorites-list {
  display: grid;
  gap: 5px;
  max-height: 230px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.favorites-list[hidden] {
  display: none;
}

.favorites-empty {
  margin: 0;
  padding: 9px 10px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.favorites-empty[hidden] {
  display: none;
}

.favorite-place-item {
  border: 1px solid var(--border);
}

.favorite-place-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.favorite-place-open,
.favorite-place-remove,
.favorite-place-edit-toggle {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.favorite-place-open {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  padding: 6px 8px;
  text-align: left;
}

.favorite-place-actions {
  display: flex;
}

.favorite-place-open:hover,
.favorite-place-open:focus-visible,
.favorite-place-remove:hover,
.favorite-place-remove:focus-visible,
.favorite-place-edit-toggle:hover,
.favorite-place-edit-toggle:focus-visible {
  background: color-mix(
    in srgb,
    var(--accent) 10%,
    transparent
  );
}

.favorite-place-open > span:first-child {
  display: grid;
  place-items: center;
}

.favorite-place-open > span:last-child {
  min-width: 0;
}

.favorite-place-open strong,
.favorite-place-open small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-place-open strong {
  font-size: 0.74rem;
}

.favorite-place-open small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.64rem;
}

.favorite-place-open small.favorite-place-note {
  font-style: italic;
}

.favorite-place-edit-toggle,
.favorite-place-remove {
  border-left: 1px solid var(--border);
  width: 36px;
  font-size: 1rem;
}

.favorite-place-edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}

.favorite-place-edit-form[hidden] {
  display: none;
}

.favorite-place-edit-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--muted);
}

.favorite-place-edit-form input,
.favorite-place-edit-form textarea {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
  font-size: 0.74rem;
  color: var(--text);
  background: var(--surface, transparent);
  resize: vertical;
}

.favorite-place-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.favorite-place-edit-save,
.favorite-place-edit-cancel {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 12px;
  font-size: 0.72rem;
  cursor: pointer;
  background: transparent;
  color: var(--text);
}

.favorite-place-edit-save {
  border-color: var(--accent);
  color: var(--accent);
}


/* Osobny panel Ulubione */
.favorites-panel,
.history-panel,
.history-panel {
  width: min(380px, calc(100vw - 24px));
}

.favorites-sheet-handle {
  display: none;
}

.favorites-toolbar {
  display: grid;
  gap: 9px;
}

.favorites-search-wrap {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--border);
  background: rgba(127, 127, 127, 0.07);
}

.favorites-search-wrap > span {
  display: grid;
  place-items: center;
}

.favorites-search-wrap input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 0;
  padding: 0 10px 0 0;
  background: transparent;
  color: var(--text);
  outline: none;
}

.menu-backup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 0 12px 12px;
}

.menu-backup-actions button {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 6px;
  place-items: center;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.menu-backup-actions button:hover,
.menu-backup-actions button:focus-visible {
  border-color: var(--accent);
  background: color-mix(
    in srgb,
    var(--accent) 10%,
    transparent
  );
}

.menu-backup-actions button span:last-child {
  font-size: 0.69rem;
  font-weight: 750;
}

.menu-backup-scope {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px 12px;
}

#menu-backup-select-all {
  align-self: flex-start;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 4px 10px;
  font-size: 0.66rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

#menu-backup-select-all:hover,
#menu-backup-select-all:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.menu-backup-scope-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  color: var(--text);
  cursor: pointer;
}

.menu-backup-scope-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.favorites-summary {
  display: flex;
  gap: 5px;
  margin: 11px 0 7px;
  color: var(--muted);
  font-size: 0.7rem;
}

#history-clear {
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 5px 12px;
  font-size: 0.7rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

#history-clear:hover,
#history-clear:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.favorites-summary #favorites-count {
  color: var(--accent);
  font-weight: 800;
}

.favorites-panel .favorites-list,
.history-panel .favorites-list {
  max-height: min(52vh, 480px);
  padding-bottom: 4px;
}

@media (max-width: 600px) {
  .favorites-panel {
    --favorites-sheet-height: 42vh;
    position: absolute;
    top: auto !important;
    right: 8px !important;
    bottom: 74px !important;
    left: 8px !important;
    width: auto !important;
    height: var(--favorites-sheet-height);
    max-height: calc(100vh - 90px) !important;
    min-height: 48px;
    padding: 0 14px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    transition: height 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .history-panel {
    --history-sheet-height: 42vh;
    position: absolute;
    top: auto !important;
    right: 8px !important;
    bottom: 74px !important;
    left: 8px !important;
    width: auto !important;
    height: var(--history-sheet-height);
    max-height: calc(100vh - 90px) !important;
    min-height: 48px;
    padding: 0 14px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    transition: height 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .favorites-panel.is-dragging,
  .history-panel.is-dragging {
    transition: none;
    user-select: none;
  }

  .favorites-sheet-handle,
  .history-sheet-handle {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 100%;
    height: 28px;
    margin: 0;
    border: 0;
    background: var(--panel);
    cursor: grab;
    touch-action: none;
  }

  .favorites-sheet-handle span,
  .history-sheet-handle span {
    display: block;
    width: 44px;
    height: 5px;
    background:
      color-mix(in srgb, var(--text) 35%, transparent);
  }

  .favorites-panel .legend-header,
  .history-panel .legend-header {
    position: sticky;
    top: 28px;
    z-index: 3;
    margin: 0 -14px 12px;
    padding: 9px 14px 10px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }

  .favorites-panel.is-collapsed,
  .history-panel.is-collapsed {
    padding-bottom: 0;
    overflow: hidden;
  }

  .favorites-panel.is-collapsed
  > :not(.favorites-sheet-handle),
  .history-panel.is-collapsed
  > :not(.history-sheet-handle) {
    display: none;
  }

  .favorites-panel.is-collapsed
  .favorites-sheet-handle,
  .history-panel.is-collapsed
  .history-sheet-handle {
    height: 48px;
  }

  .favorites-panel.is-collapsed
  .favorites-sheet-handle span,
  .history-panel.is-collapsed
  .history-sheet-handle span {
    width: 52px;
  }

  .favorites-panel .favorites-list,
  .history-panel .favorites-list {
    max-height: none;
  }
}


/* Telefon: Trasa, Odkrywaj i Menu mają identyczne położenie */
@media (max-width: 600px) {
  .route-panel,
  .discover-panel,
  .menu-panel {
    top: auto !important;
    right: 8px !important;
    bottom: 74px !important;
    left: 8px !important;
    width: auto !important;
    max-height: calc(100vh - 90px) !important;
    min-height: 48px !important;
    border-radius: 20px !important;
  }

  .route-panel {
    --route-sheet-height: 42vh;
    height: var(--route-sheet-height) !important;
  }

  .discover-panel {
    --discover-sheet-height: 42vh;
    height: var(--discover-sheet-height) !important;
  }

  .menu-panel {
    --menu-sheet-height: 42vh;
    height: var(--menu-sheet-height) !important;
  }
}


/* Panel informacji o miejscu */
.place-panel {
  width: min(390px, calc(100vw - 24px));
}

.trip-panel {
  width: min(390px, calc(100vw - 24px));
}

.place-sheet-handle {
  display: none;
}

.trip-sheet-handle {
  display: none;
}

.place-panel-content {
  min-height: 76px;
}

.trip-panel-content {
  min-height: 76px;
}

.place-panel .place-card {
  width: 100%;
  max-width: none;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.place-panel .place-card-image {
  width: calc(100% + 28px);
  max-width: none;
  margin: -2px -14px 14px;
  border-radius: 0;
}

.place-panel .place-card-loading {
  display: grid;
  place-items: center;
  min-height: 110px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 600px) {
  .place-panel {
    --place-sheet-height: 42vh;
    position: absolute;
    top: auto !important;
    right: 8px !important;
    bottom: 74px !important;
    left: 8px !important;
    width: auto !important;
    height: var(--place-sheet-height);
    max-height: calc(100vh - 90px) !important;
    min-height: 48px;
    padding: 0 14px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    transition: height 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .trip-panel {
    --trip-sheet-height: 42vh;
    position: absolute;
    top: auto !important;
    right: 8px !important;
    bottom: 74px !important;
    left: 8px !important;
    width: auto !important;
    height: var(--trip-sheet-height);
    max-height: calc(100vh - 90px) !important;
    min-height: 48px;
    padding: 0 14px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    transition: height 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .place-panel.is-dragging {
    transition: none;
    user-select: none;
  }

  .trip-panel.is-dragging {
    transition: none;
    user-select: none;
  }

  .place-sheet-handle {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 100%;
    height: 28px;
    margin: 0;
    border: 0;
    background: var(--panel);
    cursor: grab;
    touch-action: none;
  }

  .trip-sheet-handle {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 100%;
    height: 28px;
    margin: 0;
    border: 0;
    background: var(--panel);
    cursor: grab;
    touch-action: none;
  }

  .place-sheet-handle span {
    display: block;
    width: 44px;
    height: 5px;
    background:
      color-mix(in srgb, var(--text) 35%, transparent);
  }

  .trip-sheet-handle span {
    display: block;
    width: 44px;
    height: 5px;
    background:
      color-mix(in srgb, var(--text) 35%, transparent);
  }

  .place-panel .legend-header {
    position: sticky;
    top: 28px;
    z-index: 4;
    margin: 0 -14px 12px;
    padding: 9px 14px 10px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }

  .trip-panel .legend-header {
    position: sticky;
    top: 28px;
    z-index: 4;
    margin: 0 -14px 12px;
    padding: 9px 14px 10px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }

  .place-panel.is-collapsed {
    padding-bottom: 0;
    overflow: hidden;
  }

  .trip-panel.is-collapsed {
    padding-bottom: 0;
    overflow: hidden;
  }

  .place-panel.is-collapsed
  > :not(.place-sheet-handle) {
    display: none;
  }

  .trip-panel.is-collapsed
  > :not(.trip-sheet-handle) {
    display: none;
  }

  .place-panel.is-collapsed
  .place-sheet-handle {
    height: 48px;
  }

  .trip-panel.is-collapsed
  .trip-sheet-handle {
    height: 48px;
  }

  .place-panel.is-collapsed
  .place-sheet-handle span {
    width: 52px;
  }

  .trip-panel.is-collapsed
  .trip-sheet-handle span {
    width: 52px;
  }

  body:has(.place-panel:not([hidden]))
  .maplibregl-ctrl-bottom-left,
  body:has(.place-panel:not([hidden]))
  .maplibregl-ctrl-bottom-right,
  body:has(.trip-panel:not([hidden]))
  .maplibregl-ctrl-bottom-left,
  body:has(.trip-panel:not([hidden]))
  .maplibregl-ctrl-bottom-right {
    opacity: 0;
    pointer-events: none;
  }
}


/* Pinezka wybranego miejsca */
.selected-place-marker {
  position: relative;
  width: 34px;
  height: 44px;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgb(0 0 0 / 0.28));
}

.selected-place-marker-pin {
  position: absolute;
  left: 50%;
  top: 0;
  width: 30px;
  height: 30px;
  transform: translateX(-50%) rotate(45deg);
  border: 3px solid #fff;
  background: #e11d48;
  box-shadow: 0 3px 10px rgb(0 0 0 / 0.22);
}

.selected-place-marker-pin::after {
  content: "";
  position: absolute;
  inset: 7px;
  background: #fff;
}

/* Symbol bieżącej lokalizacji */
.user-location-marker {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
}

.user-location-marker-pulse {
  position: absolute;
  inset: 1px;
  background: rgb(37 99 235 / 0.22);
  animation: user-location-pulse 2.2s ease-out infinite;
}

.user-location-marker-dot {
  position: relative;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  background: #2563eb;
  box-shadow:
    0 0 0 1px rgb(37 99 235 / 0.45),
    0 2px 7px rgb(0 0 0 / 0.3);
}

@keyframes user-location-pulse {
  0% {
    transform: scale(0.55);
    opacity: 0.85;
  }
  70%,
  100% {
    transform: scale(1.25);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .user-location-marker-pulse {
    animation: none;
    opacity: 0.25;
  }
}


/* =========================================================
   Spójny nagłówek: logo bezpośrednio przy wyszukiwarce
   ========================================================= */
.toolbar {
  display: flex !important;
  align-items: stretch !important;
  gap: 10px !important;
}

.toolbar-primary {
  display: flex;
  align-items: stretch;
  min-width: 0;
  max-width: min(760px, calc(100vw - 86px));
  flex: 1 1 auto;
  gap: 0;
}

.toolbar-primary .brand {
  border-radius: 14px 0 0 14px !important;
  box-shadow: var(--shadow);
  background: var(--panel-muted) !important;
  background-color: var(--panel-muted) !important;
  z-index: 1;
}

.toolbar-primary .search {
  flex: 1 1 auto;
  min-width: 240px;
  border-left: 0;
  border-radius: 0 14px 14px 0 !important;
  box-shadow: var(--shadow);
}

.toolbar-actions {
  margin-left: auto !important;
}

/* =========================================================
   Menu kontekstowe mapy
   ========================================================= */
.map-context-menu {
  position: fixed;
  z-index: 80;
  width: min(260px, calc(100vw - 16px));
  padding: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 14px 38px rgb(0 0 0 / 0.24);
  backdrop-filter: blur(14px);
}

.map-context-menu[hidden] {
  display: none;
}

.map-context-menu button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.map-context-menu button:hover,
.map-context-menu button:focus-visible {
  outline: none;
  background:
    color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.map-context-menu button > span:first-child {
  display: grid;
  place-items: center;
}

.map-context-menu button > span:last-child {
  font-size: 0.82rem;
  font-weight: 720;
}

.map-context-separator {
  height: 1px;
  margin: 5px 7px;
  background: var(--border);
}



/* =========================================================
   Mobilny układ przy dolnej krawędzi
   ========================================================= */
@media (max-width: 600px) {
  .toolbar {
    position: fixed !important;
    z-index: 40 !important;
    top: auto !important;
    right: 8px !important;
    bottom: 68px !important;
    left: 8px !important;
    display: block !important;
    width: auto !important;
    max-width: none !important;
    min-height: 48px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .toolbar-primary {
    display: grid !important;
    grid-template-columns: 46px minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    gap: 0 !important;
  }

  .toolbar-primary .brand {
    grid-column: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 46px !important;
    min-width: 46px !important;
    height: 48px !important;
    min-height: 48px !important;
    margin: 0 !important;
    padding: 4px 6px !important;
    border-radius: 14px 0 0 14px !important;
    overflow: hidden !important;
  }

  .toolbar-primary .brand strong {
    display: none !important;
  }

  .toolbar-primary .brand-logo {
    display: block !important;
    width: 29px !important;
    height: 38px !important;
    max-width: 29px !important;
    object-fit: contain !important;
  }

  .toolbar-primary .search {
    grid-column: 2 !important;
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 48px !important;
    min-height: 48px !important;
    margin: 0 !important;
    border-left: 0 !important;
    border-radius: 0 14px 14px 0 !important;
    overflow: hidden !important;
  }

  .toolbar-primary .search input {
    display: block !important;
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .toolbar-primary .search button {
    flex: 0 0 auto !important;
  }

  .toolbar-actions,
  .toolbar .search #route-button,
  .toolbar .search #discover-button,
  .mobile-search-logo {
    display: none !important;
  }

  .mobile-bottom-nav {
    position: fixed !important;
    z-index: 40 !important;
    top: auto !important;
    right: 8px !important;
    bottom: 8px !important;
    left: 8px !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    width: auto !important;
    min-height: 54px !important;
    margin: 0 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
  }

  .mobile-bottom-action {
    display: flex !important;
    min-width: 0 !important;
    min-height: 54px !important;
  }

  body {
    padding-bottom: 130px !important;
  }

  .route-panel,
  .discover-panel,
  .menu-panel,
  .favorites-panel,
  .history-panel,
  .place-panel,
  .trip-panel,
  .legend-panel {
    bottom: 130px !important;
    max-height: calc(100vh - 146px) !important;
  }

  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right {
    bottom: 130px !important;
  }
}


/* =========================================================
   Uniwersalny kanciasty język kształtów
   ========================================================= */
:root {
  --ui-radius: 4px;
}

.toolbar,
.toolbar-primary .brand,
.toolbar-primary .search,
.toolbar-actions,
.mobile-bottom-nav,
.mobile-bottom-action,
.legend-panel,
.route-panel,
.discover-panel,
.menu-panel,
.favorites-panel,
.history-panel,
.place-panel,
.trip-panel,
.about-panel,
.backup-panel,
.map-context-menu,
.map-context-menu button,
.menu-action,
.icon-button,
.search,
.search input,
.search button,
.status,
.fatal-error,
.place-card,
.favorite-place-item,
.discover-result-item,
.route-result-item,
.autocomplete,
.search-history,
button,
input,
select,
textarea {
  border-radius: var(--ui-radius) !important;
}

.map-context-separator,
.route-sheet-handle span,
.place-sheet-handle span,
.trip-sheet-handle span,
.discover-sheet-handle span,
.menu-sheet-handle span,
.favorites-sheet-handle span {
  border-radius: 0 !important;
}

/* Wyjątki: markery lokalizacji pozostają okrągłe. */
.user-location-marker,
.user-location-marker *,
.selected-place-marker-pin::after,
.context-point-marker,
.context-point-marker-dot {
  border-radius: 50% !important;
}


.context-point-marker {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: translateZ(0);
}

.context-point-marker-dot {
  width: 14px;
  height: 14px;
  border: 3px solid #fff;
  background: #e11d48;
  box-shadow:
    0 0 0 1px rgb(225 29 72 / 0.45),
    0 2px 8px rgb(0 0 0 / 0.28);
}


/* =========================================================
   Mobilne podpowiedzi i historia nad dolnym paskiem
   ========================================================= */
@media (max-width: 600px) {
  .search-autocomplete,
  .autocomplete,
  .autocomplete-list,
  .search-suggestions,
  .search-history,
  .search-history-list {
    position: fixed !important;
    z-index: 55 !important;
    right: 8px !important;
    bottom: 126px !important;
    left: 8px !important;
    top: auto !important;
    width: auto !important;
    max-height: min(46vh, 360px) !important;
    overflow-y: auto !important;
    margin: 0 !important;
    border-radius: var(--ui-radius) !important;
  }

  .search {
    position: relative !important;
  }

  .search > [role="listbox"],
  .search > ul:not(.search-inline-actions),
  .search > .history-list {
    position: fixed !important;
    z-index: 55 !important;
    right: 8px !important;
    bottom: 126px !important;
    left: 8px !important;
    top: auto !important;
    width: auto !important;
    max-height: min(46vh, 360px) !important;
    overflow-y: auto !important;
  }
}


/* =========================================================
   Ostre prostokąty w całym interfejsie
   ========================================================= */
:root {
  --ui-radius: 0px;
}

.toolbar,
.toolbar-primary,
.toolbar-primary .brand,
.toolbar-primary .search,
.toolbar-actions,
.mobile-bottom-nav,
.mobile-bottom-action,
.legend-panel,
.route-panel,
.discover-panel,
.menu-panel,
.favorites-panel,
.history-panel,
.place-panel,
.about-panel,
.backup-panel,
.map-context-menu,
.map-context-menu button,
.menu-action,
.icon-button,
.search,
.search input,
.search button,
.status,
.fatal-error,
.place-card,
.favorite-place-item,
.discover-result-item,
.route-result-item,
.autocomplete,
.autocomplete-floating,
.autocomplete-list,
.search-history,
button,
input,
select,
textarea {
  border-radius: 0 !important;
}

/* Pinezka informacji o miejscu: dokładnie taki sam punkt jak prawy klik. */
.selected-place-marker {
  width: 22px !important;
  height: 22px !important;
  display: grid !important;
  place-items: center !important;
  pointer-events: none !important;
  filter: none !important;
}

.selected-place-marker-dot {
  width: 14px;
  height: 14px;
  border: 3px solid #fff;
  border-radius: 50% !important;
  background: #e11d48;
  box-shadow:
    0 0 0 1px rgb(225 29 72 / 0.45),
    0 2px 8px rgb(0 0 0 / 0.28);
}

/* Stara pinezka typu łezka nie jest już używana. */
.selected-place-marker-pin {
  display: none !important;
}

/* Punkty trasy mają wskazywać dokładny środek współrzędnej. */
.route-marker,
.route-waypoint-marker,
.route-point-marker,
.maplibregl-marker:has(.route-marker),
.maplibregl-marker:has(.route-waypoint-marker),
.maplibregl-marker:has(.route-point-marker) {
}

.route-marker,
.route-waypoint-marker,
.route-point-marker {
  margin: 0 !important;
}


/* =========================================================
   Dokładne markery punktów trasy
   Współrzędna znajduje się w geometrycznym środku znacznika.
   ========================================================= */
.route-letter-marker {
  display: grid !important;
  place-items: center !important;
  width: 24px !important;
  height: 24px !important;
  margin: 0 !important;
  border: 3px solid #fff !important;
  border-radius: 50% !important;
  color: var(--panel) !important;
  box-shadow:
    0 0 0 1px rgb(0 0 0 / 0.2),
    0 2px 8px rgb(0 0 0 / 0.3) !important;

}

.route-letter-marker > span {
  display: grid !important;
  place-items: center !important;
  width: 100% !important;
  height: 100% !important;
  
  line-height: 1 !important;
}

.maplibregl-marker:has(.route-letter-marker) {
  margin: 0 !important;
}


/* =========================================================
   Komunikaty mobilne nad dolnym paskiem wyszukiwania
   ========================================================= */
@media (max-width: 600px) {
  .status {
    position: fixed !important;
    z-index: 70 !important;
    top: auto !important;
    right: 8px !important;
    bottom: 126px !important;
    left: 8px !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    
  }
}




/* =========================================================
   UI Cleanup — kolory głównych akcji
   ========================================================= */

/* Wspólne białe powierzchnie */
.mobile-bottom-nav,
#mobile-discover-button,
#mobile-menu-button,
#discover-button {
  background: var(--panel) !important;
  background-color: var(--panel) !important;
  color: var(--text) !important;
}

/* Główna akcja: Szukaj — ikona lupy na czerwonym tle */
#search-button {
  background: var(--accent) !important;
  background-color: var(--accent) !important;
  color: var(--panel) !important;
}

/* Trasa jest trybem: białe/panelowe tło i czerwony tekst */
#route-button,
#mobile-route-button {
  background: var(--panel) !important;
  background-color: var(--panel) !important;
  color: var(--accent) !important;
}

/* Aktywny panel Trasa */
#route-button.is-active,
#route-button[aria-expanded="true"],
#mobile-route-button.is-active,
#mobile-route-button[aria-expanded="true"] {
  background: var(--accent) !important;
  background-color: var(--accent) !important;
  color: var(--panel) !important;
}

/* Przyciemnienie czerwonej akcji Szukaj */
#search-button:hover,
#search-button:focus-visible {
  background:
    color-mix(in srgb, var(--accent) 84%, #000) !important;
  color: var(--panel) !important;
}

#route-button:hover,
#mobile-route-button:hover,
#route-button:focus-visible,
#mobile-route-button:focus-visible {
  background:
    color-mix(in srgb, var(--panel) 88%, var(--text)) !important;
  color: var(--accent) !important;
}

#route-button.is-active:hover,
#route-button[aria-expanded="true"]:hover,
#mobile-route-button.is-active:hover,
#mobile-route-button[aria-expanded="true"]:hover {
  background:
    color-mix(in srgb, var(--accent) 84%, #000) !important;
  color: var(--panel) !important;
}

/* Przyciemnienie białych akcji */
#mobile-discover-button:hover,
#mobile-menu-button:hover,
#discover-button:hover,
#mobile-discover-button:focus-visible,
#mobile-menu-button:focus-visible,
#discover-button:focus-visible {
  background:
    color-mix(in srgb, var(--panel) 88%, var(--text)) !important;
  background-color:
    color-mix(in srgb, var(--panel) 88%, var(--text)) !important;
  color: var(--text) !important;
}

/* Stan wciśnięcia */
#search-button:active {
  background:
    color-mix(in srgb, var(--accent) 70%, #000) !important;
}

#route-button:active,
#mobile-route-button:active {
  background:
    color-mix(in srgb, var(--panel) 78%, var(--text)) !important;
  color: var(--accent) !important;
}

#mobile-discover-button:active,
#mobile-menu-button:active,
#discover-button:active {
  background:
    color-mix(in srgb, var(--panel) 76%, var(--text)) !important;
}

/* Nie używamy globalnego filtra, bo zmieniał też ikony i tekst. */
#search-button,
#route-button,
#mobile-route-button,
#mobile-discover-button,
#mobile-menu-button,
#discover-button {
  filter: none !important;
  transition:
    background-color 140ms ease,
    color 140ms ease !important;
}

/* =========================================================
   UI Cleanup — widoczne i dokładne markery A/B
   ========================================================= */
.route-letter-marker,
.route-letter-marker.maplibregl-marker {
  display: grid !important;
  place-items: center !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  min-height: 26px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 3px solid #fff !important;
  border-radius: 50% !important;
  color: var(--panel) !important;
  font-size: 0.78rem !important;
  font-weight: 850 !important;
  line-height: 1 !important;
  pointer-events: auto !important;
  z-index: 8 !important;
  box-shadow:
    0 0 0 1px rgb(0 0 0 / 0.25),
    0 2px 8px rgb(0 0 0 / 0.34) !important;
}

.route-letter-marker.route-a,
.route-letter-marker.route-a.maplibregl-marker {
  background: #16a34a !important;
  background-color: #16a34a !important;
}

.route-letter-marker.route-b,
.route-letter-marker.route-b.maplibregl-marker {
  background: #dc2626 !important;
  background-color: #dc2626 !important;
}

.route-letter-marker > span {
  display: grid !important;
  place-items: center !important;
  width: 100% !important;
  height: 100% !important;
  color: var(--panel) !important;
  
  line-height: 1 !important;
}


/* MapLibre ustawia pozycję markerów przez inline transform.
   Nie wolno go nadpisywać, bo marker trafia do lewego górnego rogu. */
.route-letter-marker.maplibregl-marker,
.maplibregl-marker.route-letter-marker {
  transform: var(--maplibre-marker-transform, unset);
}



/* Motywowo poprawne powierzchnie */
.mobile-bottom-nav,
#mobile-discover-button,
#mobile-menu-button,
#discover-button,
#route-button,
#mobile-route-button {
  background: var(--panel) !important;
  background-color: var(--panel) !important;
  color: var(--text);
}

.toolbar-primary .search input::placeholder {
  color: var(--muted) !important;
}

/* Czerwone akcenty po deklaracji powierzchni panelowych */
#search-button {
  background: var(--accent) !important;
  background-color: var(--accent) !important;
  color: var(--panel) !important;
}

#route-button,
#mobile-route-button {
  color: var(--accent) !important;
}

#route-button.is-active,
#route-button[aria-expanded="true"],
#mobile-route-button.is-active,
#mobile-route-button[aria-expanded="true"] {
  background: var(--accent) !important;
  background-color: var(--accent) !important;
  color: var(--panel) !important;
}



/* =========================================================
   Mobilne przyciski: ikona nad nazwą, trzy kolumny w jednym rzędzie
   ========================================================= */
@media (max-width: 600px) {
  .mobile-bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .mobile-bottom-action {
    display: grid !important;
    grid-template-rows: auto auto !important;
    grid-template-columns: 1fr !important;
    place-items: center !important;
    align-content: center !important;
    justify-content: center !important;
    gap: 3px !important;
    min-width: 0 !important;
    padding: 6px 8px !important;
    color: var(--accent) !important;
    text-align: center !important;
  }

  .mobile-bottom-action > span:first-child {
    display: block !important;
    grid-row: 1 !important;
    margin: 0 !important;
    font-size: 1.2rem !important;
    line-height: 1 !important;
    text-align: center !important;
  }

  .mobile-bottom-action > span:last-child {
    display: block !important;
    grid-row: 2 !important;
    margin: 0 !important;
    color: var(--accent) !important;
    font-size: 0.72rem !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    text-align: center !important;
  }

  #mobile-route-button,
  #mobile-discover-button,
  #mobile-menu-button {
    color: var(--accent) !important;
  }

  #mobile-route-button > span:last-child,
  #mobile-discover-button > span:last-child,
  #mobile-menu-button > span:last-child {
    color: var(--accent) !important;
  }

  /* Aktywny przycisk zachowuje czerwone tło i biały tekst. */
  #mobile-route-button.is-active,
  #mobile-route-button[aria-expanded="true"],
  #mobile-discover-button.is-active,
  #mobile-discover-button[aria-expanded="true"],
  #mobile-menu-button.is-active,
  #mobile-menu-button[aria-expanded="true"] {
    background: var(--accent) !important;
    background-color: var(--accent) !important;
    color: var(--panel) !important;
  }

  #mobile-route-button.is-active > span:last-child,
  #mobile-route-button[aria-expanded="true"] > span:last-child,
  #mobile-discover-button.is-active > span:last-child,
  #mobile-discover-button[aria-expanded="true"] > span:last-child,
  #mobile-menu-button.is-active > span:last-child,
  #mobile-menu-button[aria-expanded="true"] > span:last-child {
    color: var(--panel) !important;
  }
}


/* =========================================================
   Wyśrodkowane komunikaty mobilne
   ========================================================= */
@media (max-width: 600px) {
  .status {
    position: fixed !important;
    z-index: 70 !important;
    top: auto !important;
    right: 50% !important;
    bottom: 126px !important;
    left: auto !important;
    width: min(calc(100vw - 24px), 420px) !important;
    max-width: min(calc(100vw - 24px), 420px) !important;
    margin: 0 !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
    transform: translateX(50%) !important;
    box-sizing: border-box !important;
    text-align: center !important;
  }
}


/* =========================================================
   Desktop: aktywne Odkrywaj i Menu na czerwono
   ========================================================= */
@media (min-width: 601px) {
  #discover-button.is-active,
  #discover-button[aria-expanded="true"],
  #menu-button.is-active,
  #menu-button[aria-expanded="true"] {
    background: var(--accent) !important;
    background-color: var(--accent) !important;
    color: var(--panel) !important;
  }

  #discover-button.is-active:hover,
  #discover-button[aria-expanded="true"]:hover,
  #menu-button.is-active:hover,
  #menu-button[aria-expanded="true"]:hover,
  #discover-button.is-active:focus-visible,
  #discover-button[aria-expanded="true"]:focus-visible,
  #menu-button.is-active:focus-visible,
  #menu-button[aria-expanded="true"]:focus-visible {
    background:
      color-mix(in srgb, var(--accent) 84%, #000) !important;
    background-color:
      color-mix(in srgb, var(--accent) 84%, #000) !important;
    color: var(--panel) !important;
  }
}


/* =========================================================
   Większe tarcze z numerami dróg
   ========================================================= */
.road-shield,
.road-ref,
[class*="road-shield"],
[class*="road-ref"] {
  min-width: 32px !important;
  min-height: 23px !important;
  padding: 3px 8px !important;
  font-size: 0.86rem !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
}


/* =========================================================
   Telefon: otwarty panel zastępuje wyszukiwarkę i przyciski
   ========================================================= */
@media (max-width: 600px) {
  body:has(.route-panel:not([hidden])) .toolbar,
  body:has(.discover-panel:not([hidden])) .toolbar,
  body:has(.menu-panel:not([hidden])) .toolbar,
  body:has(.favorites-panel:not([hidden])) .toolbar,
  body:has(.history-panel:not([hidden])) .toolbar,
  body:has(.place-panel:not([hidden])) .toolbar,
  body:has(.trip-panel:not([hidden])) .toolbar,
  body:has(.route-panel:not([hidden])) .mobile-bottom-nav,
  body:has(.discover-panel:not([hidden])) .mobile-bottom-nav,
  body:has(.menu-panel:not([hidden])) .mobile-bottom-nav,
  body:has(.favorites-panel:not([hidden])) .mobile-bottom-nav,
  body:has(.history-panel:not([hidden])) .mobile-bottom-nav,
  body:has(.place-panel:not([hidden])) .mobile-bottom-nav,
  body:has(.trip-panel:not([hidden])) .mobile-bottom-nav {
    display: none !important;
  }

  body:has(.route-panel:not([hidden])) .route-panel,
  body:has(.discover-panel:not([hidden])) .discover-panel,
  body:has(.menu-panel:not([hidden])) .menu-panel,
  body:has(.favorites-panel:not([hidden])) .favorites-panel,
  body:has(.history-panel:not([hidden])) .history-panel,
  body:has(.place-panel:not([hidden])) .place-panel,
  body:has(.trip-panel:not([hidden])) .trip-panel {
    bottom: 8px !important;
    max-height: calc(100vh - 16px) !important;
  }

  body:has(.route-panel:not([hidden])) .maplibregl-ctrl-bottom-left,
  body:has(.discover-panel:not([hidden])) .maplibregl-ctrl-bottom-left,
  body:has(.menu-panel:not([hidden])) .maplibregl-ctrl-bottom-left,
  body:has(.favorites-panel:not([hidden])) .maplibregl-ctrl-bottom-left,
  body:has(.history-panel:not([hidden])) .maplibregl-ctrl-bottom-left,
  body:has(.place-panel:not([hidden])) .maplibregl-ctrl-bottom-left,
  body:has(.trip-panel:not([hidden])) .maplibregl-ctrl-bottom-left {
    display: none !important;
  }
}


/* =========================================================
   Zagnieżdżone podstrony Menu
   ========================================================= */
.legend-header.has-menu-back {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
}

.legend-header.has-menu-back h2 {
  min-width: 0;
  text-align: center;
}

.menu-back-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.menu-back-button[hidden] {
  display: none;
}

.menu-back-button:hover,
.menu-back-button:focus-visible {
  background: color-mix(
    in srgb,
    var(--accent) 10%,
    transparent
  );
  color: var(--accent);
}

@media (max-width: 600px) {
  .menu-subpanel {
    position: absolute;
    top: auto !important;
    right: 8px !important;
    bottom: 8px !important;
    left: 8px !important;
    width: auto !important;
    height: min(42vh, calc(100vh - 16px));
    max-height: min(42vh, calc(100vh - 16px)) !important;
    padding: 0 14px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 0;
  }

  .menu-subpanel .legend-header {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 -14px 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    backdrop-filter: blur(12px);
  }

  body:has(.legend-panel.menu-subpanel:not([hidden])) .toolbar,
  body:has(.about-panel.menu-subpanel:not([hidden])) .toolbar,
  body:has(.backup-panel.menu-subpanel:not([hidden])) .toolbar,
  body:has(.legend-panel.menu-subpanel:not([hidden])) .mobile-bottom-nav,
  body:has(.about-panel.menu-subpanel:not([hidden])) .mobile-bottom-nav,
  body:has(.backup-panel.menu-subpanel:not([hidden])) .mobile-bottom-nav {
    display: none !important;
  }

  body:has(.legend-panel.menu-subpanel:not([hidden]))
  .maplibregl-ctrl-bottom-left,
  body:has(.about-panel.menu-subpanel:not([hidden]))
  .maplibregl-ctrl-bottom-left,
  body:has(.backup-panel.menu-subpanel:not([hidden]))
  .maplibregl-ctrl-bottom-left {
    display: none !important;
  }
}


/* =========================================================
   Ostateczna, wspólna wysokość mobilnego panelu Informacje
   ========================================================= */
@media (max-width: 600px) {
  body:has(.place-panel:not([hidden])) .place-panel {
    --place-sheet-height: 42dvh;
    height: var(--place-sheet-height) !important;
    max-height: calc(100dvh - 16px) !important;
    min-height: 48px !important;
    bottom: 8px !important;
    overflow-y: auto !important;
  }

  body:has(.trip-panel:not([hidden])) .trip-panel {
    --trip-sheet-height: 42dvh;
    height: var(--trip-sheet-height) !important;
    max-height: calc(100dvh - 16px) !important;
    min-height: 48px !important;
    bottom: 8px !important;
    overflow-y: auto !important;
  }

  body:has(.place-panel:not([hidden]))
  .place-panel.is-collapsed {
    --place-sheet-height: 48px !important;
    height: 48px !important;
    max-height: 48px !important;
    min-height: 48px !important;
    overflow: hidden !important;
  }

  body:has(.trip-panel:not([hidden]))
  .trip-panel.is-collapsed {
    --trip-sheet-height: 48px !important;
    height: 48px !important;
    max-height: 48px !important;
    min-height: 48px !important;
    overflow: hidden !important;
  }

  body:has(.place-panel:not([hidden]))
  .place-panel.is-collapsed
  > :not(.place-sheet-handle) {
    display: none !important;
  }

  body:has(.trip-panel:not([hidden]))
  .trip-panel.is-collapsed
  > :not(.trip-sheet-handle) {
    display: none !important;
  }

  body:has(.place-panel:not([hidden]))
  .place-panel.is-collapsed
  .place-sheet-handle {
    height: 48px;
  }

  body:has(.trip-panel:not([hidden]))
  .trip-panel.is-collapsed
  .trip-sheet-handle {
    height: 48px;
  }
}


/* Nawigacja wstecz z panelu Informacje */
.place-panel-header {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
}

.place-panel-header h2 {
  min-width: 0;
  text-align: center;
}

.place-panel-back[hidden] {
  visibility: hidden;
  display: grid;
}


/* =========================================================
   Uniwersalny standard wszystkich mobilnych paneli
   ========================================================= */
@media (max-width: 600px) {
  :root {
    --mobile-panel-default-height: 42dvh;
    --mobile-panel-collapsed-height: 48px;
    --mobile-panel-bottom-gap: 8px;
  }

  .route-panel:not([hidden]),
  .discover-panel:not([hidden]),
  .menu-panel:not([hidden]),
  .favorites-panel:not([hidden]),
  .history-panel:not([hidden]),
  .place-panel:not([hidden]),
  .trip-panel:not([hidden]),
  .menu-subpanel:not([hidden]) {
    bottom: var(--mobile-panel-bottom-gap) !important;
    min-height: var(--mobile-panel-collapsed-height) !important;
    max-height: calc(100dvh - 16px) !important;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .route-panel:not([hidden]) {
    height: var(--route-sheet-height, var(--mobile-panel-default-height)) !important;
  }

  .discover-panel:not([hidden]) {
    height: var(--discover-sheet-height, var(--mobile-panel-default-height)) !important;
  }

  .menu-panel:not([hidden]),
  .menu-subpanel:not([hidden]) {
    height: var(--menu-sheet-height, var(--mobile-panel-default-height)) !important;
  }

  .favorites-panel:not([hidden]) {
    height: var(--favorites-sheet-height, var(--mobile-panel-default-height)) !important;
  }

  .history-panel:not([hidden]) {
    height: var(--history-sheet-height, var(--mobile-panel-default-height)) !important;
  }

  .place-panel:not([hidden]) {
    height: var(--place-sheet-height, var(--mobile-panel-default-height)) !important;
  }

  .trip-panel:not([hidden]) {
    height: var(--trip-sheet-height, var(--mobile-panel-default-height)) !important;
  }

  .route-panel.is-collapsed,
  .discover-panel.is-collapsed,
  .menu-panel.is-collapsed,
  .favorites-panel.is-collapsed,
  .history-panel.is-collapsed,
  .place-panel.is-collapsed,
  .trip-panel.is-collapsed,
  .menu-subpanel.is-collapsed {
    height: var(--mobile-panel-collapsed-height) !important;
    min-height: var(--mobile-panel-collapsed-height) !important;
    max-height: var(--mobile-panel-collapsed-height) !important;
    overflow: hidden !important;
  }

  .route-panel.is-dragging,
  .discover-panel.is-dragging,
  .menu-panel.is-dragging,
  .favorites-panel.is-dragging,
  .history-panel.is-dragging,
  .place-panel.is-dragging,
  .trip-panel.is-dragging,
  .menu-subpanel.is-dragging {
    transition: none !important;
  }
}


@media (max-width: 600px) {
  .legend-panel.menu-subpanel:not([hidden]) {
    height: var(
      --legend-sheet-height,
      var(--mobile-panel-default-height)
    ) !important;
  }

  .about-panel.menu-subpanel:not([hidden]) {
    height: var(
      --about-sheet-height,
      var(--mobile-panel-default-height)
    ) !important;
  }

  .backup-panel.menu-subpanel:not([hidden]) {
    height: var(
      --backup-sheet-height,
      var(--mobile-panel-default-height)
    ) !important;
  }

  .legend-panel.menu-subpanel.is-collapsed,
  .about-panel.menu-subpanel.is-collapsed,
  .backup-panel.menu-subpanel.is-collapsed {
    height: var(
      --mobile-panel-collapsed-height
    ) !important;
    min-height: var(
      --mobile-panel-collapsed-height
    ) !important;
    max-height: var(
      --mobile-panel-collapsed-height
    ) !important;
    overflow: hidden !important;
  }
}


/* =========================================================
   Uniwersalny wygląd paneli — bez zmiany działającej logiki
   ========================================================= */
.app-sheet {
  --app-sheet-corner-radius: 4px;
  box-sizing: border-box;
  background: var(--panel) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--app-sheet-corner-radius) !important;
  box-shadow: var(--shadow) !important;
}

.app-sheet,
.app-sheet *,
.menu-panel,
.legend-panel,
.route-panel,
.favorites-panel,
.history-panel,
.place-panel,
.trip-panel,
.about-panel,
.backup-panel,
.discover-panel {
  border-radius: min(
    var(--app-sheet-corner-radius),
    4px
  );
}

.app-sheet__header {
  min-height: 52px;
  display: grid !important;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 8px 14px !important;
  border-bottom: 1px solid var(--border);
  background: var(--panel) !important;
  border-radius: 0 !important;
  touch-action: none;
}

.app-sheet__header:not(.has-menu-back)::before {
  content: "";
  grid-column: 1;
}

.app-sheet__header h2 {
  grid-column: 2;
  margin: 0;
  min-width: 0;
  text-align: center;
}

.app-sheet__header .menu-back-button {
  grid-column: 1;
}

.app-sheet__header .legend-close {
  grid-column: 3;
}

.app-sheet__handle {
  border-radius: 0 !important;
}

@media (max-width: 600px) {
  .app-sheet:not([hidden]) {
    border-radius: var(--app-sheet-corner-radius) !important;
  }

  .app-sheet__handle {
    border-radius: 0 !important;
  }

  .app-sheet__handle::before {
    border-radius: 2px !important;
  }
}

/* Ostrzejsze rogi również dla pozostałych głównych elementów UI. */
button,
input,
select,
textarea,
.search-bar,
.search-results,
.context-menu,
.maplibregl-popup-content,
.modal,
.card,
.place-card {
  border-radius: 4px !important;
}


/* Uniwersalny reset: wszystkie elementy interfejsu mają ostre rogi (0 px).
   Jedyne, celowe wyjątki (okrągłe przyciski, plakietki) są zaznaczone
   lokalnie przy swoich selektorach z użyciem !important, np. border-radius: 50% !important. */
*,
*::before,
*::after {
  border-radius: 0 !important;
}

.app-sheet__header,
.legend-header,
.place-panel-header {
  padding-bottom: 16px !important;
  margin-bottom: 12px !important;
}

:root {
  --panel-radius: 0px !important;
  --app-sheet-corner-radius: 0px !important;
}

@media (max-width: 600px) {
  #legend-panel,
  #about-panel,
  #backup-panel,
  #route-panel,
  #favorites-panel,
  #place-panel,
  #discover-panel,
  #menu-panel,
  .legend-panel,
  .about-panel,
  .backup-panel,
  .route-panel,
  .favorites-panel,
  .history-panel,
  .place-panel,
  .trip-panel,
  .discover-panel,
  .menu-panel,
  .menu-subpanel,
  .app-sheet,
  .app-sheet::before,
  .app-sheet::after,
  .app-sheet > *,
  .sheet-handle,
  .app-sheet__handle,
  .legend-header,
  .place-panel-header {
    clip-path: none !important;
    mask-image: none !important;
    -webkit-mask-image: none !important;
  }
}


/* =========================================================
   Jeden uniwersalny szkielet wszystkich paneli
   ========================================================= */
:root {
  --panel-shell-handle-height: 28px;
  --panel-shell-padding-x: 14px;
  --panel-shell-header-gap: 12px;
}

@media (max-width: 600px) {
  .panel-shell:not([hidden]) {
    position: absolute !important;
    top: auto !important;
    right: 8px !important;
    bottom: 8px !important;
    left: 8px !important;
    width: auto !important;
    padding: 0 var(--panel-shell-padding-x) 14px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }

  .panel-shell > .panel-shell__handle {
    position: sticky !important;
    top: 0 !important;
    z-index: 40 !important;
    display: grid !important;
    place-items: center !important;
    width: 100% !important;
    height: var(--panel-shell-handle-height) !important;
    min-height: var(--panel-shell-handle-height) !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: var(--panel) !important;
    cursor: grab !important;
    touch-action: none !important;
  }

  .panel-shell > .panel-shell__handle:active {
    cursor: grabbing !important;
  }

  .panel-shell > .panel-shell__handle > span {
    display: block !important;
    width: 44px !important;
    height: 5px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: color-mix(
      in srgb,
      var(--text) 35%,
      transparent
    ) !important;
  }

  .panel-shell > .panel-shell__header,
  .panel-shell.menu-subpanel > .panel-shell__header {
    position: sticky !important;
    top: var(--panel-shell-handle-height) !important;
    z-index: 39 !important;
    min-height: 52px !important;
    margin: 0
      calc(var(--panel-shell-padding-x) * -1)
      var(--panel-shell-header-gap) !important;
    padding: 9px var(--panel-shell-padding-x) 10px !important;
    border-bottom: 1px solid var(--border) !important;
    background: var(--panel) !important;
    backdrop-filter: blur(12px);
  }

  .panel-shell.is-collapsed >
  .panel-shell__handle {
    height: 48px !important;
    min-height: 48px !important;
  }

  .panel-shell.is-collapsed >
  .panel-shell__handle > span {
    width: 52px !important;
  }
}
