:root {
  --red: #e0432b;
  --orange: #f0a202;
  --gray: #c7cad1;
  --ink: #1b1f24;
  --paper: #ffffff;
  --muted: #6b7280;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

.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;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #eef0f3;
}

#map {
  position: fixed;
  inset: 0;
}

/* ---------- top bar ---------- */
#topbar {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--paper);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}
.icon-btn:active { background: #f0f0f0; }

#searchwrap {
  flex: 1 1 auto;
  position: relative;
}

#search {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 22px;
  padding: 0 16px;
  font-size: 16px;
  background: var(--paper);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  outline: none;
}

#suggestions {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  max-height: 50vh;
  overflow-y: auto;
}
#suggestions button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: none;
  background: none;
  font-size: 15px;
  border-bottom: 1px solid #eee;
}
#suggestions button:last-child { border-bottom: none; }
#suggestions button:active { background: #f5f5f5; }
#suggestions .sug-sub { color: var(--muted); font-size: 13px; margin-left: 8px; }
#suggestions .sug-empty { padding: 14px 16px; color: var(--muted); font-size: 14px; }

#share-wrap { position: relative; flex: 0 0 auto; }

#share-menu[hidden] { display: none; }
#share-menu {
  position: absolute;
  top: 50px;
  right: 0;
  z-index: 1001;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 170px;
}
.share-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
.share-item:active { background: #f0f0f0; }

/* ---------- floating map controls ---------- */
.map-float-btn {
  position: fixed;
  right: 10px;
  top: calc(64px + var(--safe-top));
  z-index: 900;
}

/* ---------- legend ---------- */
body.sheet-open #legend { display: none; }
#legend {
  position: fixed;
  left: 10px;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 900;
  background: rgba(255,255,255,.92);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  display: flex;
  row-gap: 8px;
  column-gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  max-width: calc(100vw - 20px);
}
#legend-coffee {
  flex: 1 1 100%;
  order: 10;
  margin: 2px 0 0;
  padding: 6px 10px;
  border-radius: 12px;
  background: #fdf0d5;
  color: #92600a !important;
  font-weight: 600;
  text-decoration: none !important;
  white-space: nowrap;
  text-align: center;
  font-size: 12px;
}
#legend-coffee:active { background: #fbe4b8; }
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.dot.red { background: var(--red); }
.dot.orange { background: var(--orange); }
.dot.gray { background: var(--gray); }

/* ---------- bottom sheet ---------- */
#sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.25);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
body.sheet-open #sheet-backdrop { opacity: 1; pointer-events: auto; }

#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.25);
  max-height: 70vh;
  transform: translateY(105%);
  transition: transform .25s ease;
  padding: 8px 20px calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
}
body.sheet-open #sheet { transform: translateY(0); }

.sheet-handle {
  width: 40px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 6px auto 10px;
}

#sheet-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--muted);
  width: 32px;
  height: 32px;
}

#sheet-content { overflow-y: auto; }

#sheet-title { margin: 0 0 2px; font-size: 22px; }
#sheet-sub { color: var(--muted); font-size: 14px; margin-bottom: 10px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.status-badge.zakaz { background: #fce6e2; color: #a3271a; }
.status-badge.czesciowy { background: #fdf0d5; color: #92600a; }
.status-badge.brak { background: #ffffff; color: #33383f; border: 1px solid #dcdfe4; }
.status-badge.nieznany { background: #eceef1; color: #555b66; }

#sheet-details { font-size: 14px; color: #444; margin-bottom: 6px; line-height: 1.5; }
#sheet-details a { color: #1b6ec2; }

#sheet h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 14px 0 6px; }

#sheet-neighbors {
  list-style: none;
  margin: 0;
  padding: 0;
}
#sheet-neighbors li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 15px;
}
#sheet-neighbors li:last-child { border-bottom: none; }
#sheet-neighbors button {
  all: unset;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
}
#sheet-neighbors .nb-name { display: flex; align-items: center; gap: 8px; }
.nb-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f1f2f4;
  color: #555;
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
}

/* ---------- info modal ---------- */
#info-modal { display: none; }
#info-modal.open { display: block; }
#info-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1300;
}
#info-content {
  position: fixed;
  z-index: 1400;
  left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  background: var(--paper);
  width: min(420px, calc(100vw - 32px));
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
#info-content h2 { margin-top: 4px; margin-bottom: 10px; }
#info-content p { font-size: 14px; line-height: 1.6; color: #333; }
.tagline { font-style: italic; color: var(--muted) !important; margin-bottom: 18px; }
#info-close {
  position: absolute; top: 12px; right: 14px;
  border: none; background: none; font-size: 18px; color: var(--muted);
}

.info-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.pill-link {
  display: block;
  width: 100%;
  text-align: center;
  padding: 12px 16px;
  border-radius: 24px;
  border: none;
  background: #f1f2f4;
  color: var(--ink) !important;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
}
.pill-link:active { background: #e6e7ea; }
.pill-link-primary { background: var(--ink); color: #fff !important; }
.pill-link-primary:active { background: #333; }

#contact-form[hidden] { display: none; }
#contact-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eee;
}
#contact-form textarea,
#contact-form input {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
#contact-form textarea:focus,
#contact-form input:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
#contact-status { font-size: 13px; color: var(--muted); margin: 0; min-height: 1em; }

.disclaimer {
  background: #fff8ec;
  border-left: 3px solid var(--orange);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.disclaimer p { margin: 0; }
.disclaimer-headline { font-weight: 700; color: var(--ink) !important; font-size: 14px !important; margin-bottom: 6px !important; }
.disclaimer-help { font-size: 13px !important; color: #444 !important; margin-bottom: 4px !important; }
.disclaimer-help a { color: #1b6ec2; font-weight: 600; }
.disclaimer-meta { font-size: 12px !important; color: var(--muted) !important; }

.meta { font-size: 12px !important; color: var(--muted) !important; }

/* ---------- user location marker ---------- */
.user-location-marker { position: relative; width: 40px; height: 40px; }
.user-location-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  background: #1a73e8;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(26,115,232,.35), 0 1px 4px rgba(0,0,0,.35);
  transform: translate(-50%, -50%);
}
.user-location-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  background: rgba(26,115,232,.3);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1);
  animation: user-location-pulse-anim 2s ease-out infinite;
}
@keyframes user-location-pulse-anim {
  0% { transform: translate(-50%, -50%) scale(1); opacity: .8; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

/* ---------- cookie banner ---------- */
#cookie-banner[hidden] { display: none; }
#cookie-banner {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 1500;
  background: var(--paper);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  max-width: 480px;
  margin: 0 auto;
}
#cookie-banner p {
  font-size: 13px;
  line-height: 1.5;
  color: #333;
  margin: 0 0 12px;
}
#cookie-banner a { color: #1b6ec2; }
#cookie-banner .cookie-actions {
  display: flex;
  gap: 10px;
}
#cookie-banner .pill-link {
  width: auto;
  flex: 1 1 0;
  padding: 10px 14px;
  font-size: 13px;
}

/* leaflet control tweaks */
.leaflet-control-zoom { display: none; }
.leaflet-control-attribution { font-size: 10px !important; }

/* ---------- desktop / wide screens ---------- */
@media (min-width: 700px) {
  #topbar {
    left: 16px;
    right: auto;
    width: 480px;
  }
  #legend { left: 16px; }
  .map-float-btn { right: 16px; }

  #sheet {
    left: 16px;
    right: auto;
    bottom: 16px;
    width: 400px;
    max-height: min(70vh, 640px);
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    transform: translateY(20px) scale(.98);
    opacity: 0;
    pointer-events: none;
    transition: transform .2s ease, opacity .2s ease;
  }
  body.sheet-open #sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
  #sheet-backdrop { display: none; }
}
