/* Кольори підставляються з Telegram.WebApp.themeParams (app.js); тут — запасні значення */
:root {
  --bg: #ffffff; --text: #111111; --hint: #8a8a8e; --sec-bg: #f1f1f4;
  --btn: #2a8bd6; --btn-text: #ffffff; --danger: #d63c3c;
  --top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sec-bg); color: var(--text);
  font: 15px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
#map { position: fixed; inset: 0; background: var(--sec-bg); }
button { font: inherit; cursor: pointer; }

/* фільтри */
#filters { position: fixed; z-index: 1000; left: 0; right: 0; top: calc(8px + var(--top)); padding: 0 8px;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
#filters::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; border-radius: 999px; padding: 7px 12px; background: var(--bg); color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.18); white-space: nowrap; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--btn); color: var(--btn-text); }

/* «Де я» і підказка */
#locate { position: fixed; z-index: 1000; right: 10px; bottom: calc(18px + var(--bottom)); border: 0; border-radius: 999px;
  padding: 11px 16px; background: var(--bg); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.25); font-weight: 600; }
#hint { position: fixed; z-index: 999; left: 10px; bottom: calc(24px + var(--bottom)); max-width: calc(100% - 140px);
  font-size: 13px; color: var(--text); background: color-mix(in srgb, var(--bg) 88%, transparent); padding: 6px 10px; border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.leaflet-control-zoom { margin-bottom: calc(70px + var(--bottom)) !important; }

/* нижня панель */
#sheet { position: fixed; z-index: 1100; left: 0; right: 0; bottom: 0; max-height: 70vh; overflow-y: auto;
  background: var(--bg); color: var(--text); border-radius: 18px 18px 0 0; padding: 8px 16px calc(14px + var(--bottom));
  box-shadow: 0 -4px 24px rgba(0,0,0,.25); }
.grip { width: 40px; height: 4px; border-radius: 2px; background: var(--hint); opacity: .5; margin: 2px auto 8px; }
#sheet h2 { font-size: 17px; margin: 0 0 8px; }
.field { display: block; margin: 0 0 10px; }
.field > span { display: block; font-size: 13px; color: var(--hint); margin-bottom: 4px; }
.field b { color: var(--danger); }
input, textarea { width: 100%; border: 1px solid color-mix(in srgb, var(--hint) 45%, transparent); border-radius: 10px; padding: 9px 10px;
  background: var(--sec-bg); color: var(--text); font: inherit; outline: none; resize: vertical; }
input:focus, textarea:focus { border-color: var(--btn); }
#cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cat { border: 2px solid transparent; border-radius: 999px; padding: 6px 10px; background: var(--sec-bg); color: var(--text); font-size: 14px; }
.cat[aria-checked="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, var(--bg)); }
#err { color: var(--danger); min-height: 1em; margin: 2px 0 8px; font-size: 14px; }
.row { display: flex; gap: 10px; }
.row button { flex: 1; border: 0; border-radius: 12px; padding: 13px; font-weight: 600; }
.pri { background: var(--btn); color: var(--btn-text); }
.pri:disabled { opacity: .6; }
.sec { background: var(--sec-bg); color: var(--text); }
.small { font-size: 12px; color: var(--hint); margin: 8px 0 0; text-align: center; }

/* маркери: кольорове коло з емодзі і «хвостиком» */
.pin { background: none; border: 0; }
.pin span { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--c); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); font-size: 17px; line-height: 1; }
.pin span::after { content: ""; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top: 7px solid #fff; border-bottom: 0; }
.pin.temp span { outline: 3px dashed var(--c); outline-offset: 3px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.me { width: 18px; height: 18px; border-radius: 50%; background: #2a8bd6; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(42,139,214,.35); }

/* кластери (свій вигляд замість стандартного) */
.cluster { background: none; }
.cluster div { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--btn); color: var(--btn-text);
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); font-weight: 700; }

/* спливаюче вікно точки */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg); color: var(--text); }
.leaflet-popup-content { margin: 12px 14px; min-width: 220px; font-size: 14px; }
.pop h3 { margin: 0 0 4px; font-size: 16px; }
.pop .tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 20%, var(--bg)); margin-bottom: 6px; }
.pop p { margin: 4px 0; white-space: pre-wrap; word-wrap: break-word; }
.pop .meta { color: var(--hint); font-size: 12px; }
.pop .tag.wait { --c: #f9a825; }
.pin.pending span { opacity: .6; outline: 2px dashed #f9a825; outline-offset: 2px; }
.pop .route { display: flex; gap: 6px; margin-top: 8px; }
.pop .route a { flex: 1; text-align: center; text-decoration: none; border-radius: 10px; padding: 8px 4px; font-weight: 600; font-size: 13px;
  background: color-mix(in srgb, var(--btn) 16%, var(--bg)); color: var(--btn); white-space: nowrap; }
.pop .ok { margin-top: 8px; width: 100%; border: 0; border-radius: 10px; padding: 8px; background: #2e9d5b; color: #fff; font-weight: 600; }
.pop .edit { margin-top: 8px; width: 100%; border: 0; border-radius: 10px; padding: 8px; background: color-mix(in srgb, var(--btn) 16%, var(--bg)); color: var(--btn); font-weight: 600; }
.pop .diff { margin: 2px 0 4px; padding-left: 18px; font-size: 13px; }
.pop .diff li { margin: 2px 0; white-space: pre-wrap; word-wrap: break-word; }
.pop .keep { margin-top: 8px; width: 100%; border: 0; border-radius: 10px; padding: 8px; background: var(--sec-bg); color: var(--text); font-weight: 600; }
.pop .del { margin-top: 8px; width: 100%; border: 0; border-radius: 10px; padding: 8px; background: color-mix(in srgb, var(--danger) 14%, var(--bg)); color: var(--danger); font-weight: 600; }

#toast { position: fixed; z-index: 1300; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--bottom)); max-width: calc(100% - 32px);
  padding: 10px 14px; border-radius: 12px; background: rgba(20,20,20,.88); color: #fff; font-size: 14px; text-align: center; }
