:root {
  --bg: #F4F6F3; --surface: #FFFFFF; --ink: #18201D; --muted: #5B6863; --line: #DDE3DF; --soft: #EAEFEB;
  --accent: #2E6A4E; --accent-ink: #FFFFFF; --accent-soft: #DDEDE4;
  --sans: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --panel-w: 320px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111614; --surface: #18201D; --ink: #E4EAE6; --muted: #98A59F; --line: #2A3430; --soft: #1F2825;
    --accent: #72C39A; --accent-ink: #0E1512; --accent-soft: #1E3529;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.layout { flex: 1; display: flex; min-height: 0; position: relative; }
.panel { width: var(--panel-w); flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); z-index: 1000; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 16px 12px; border-bottom: 1px solid var(--line); }
h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.count { margin: 2px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 18px; }
section { display: flex; flex-direction: column; gap: 8px; }
h2 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; }
.links { color: var(--muted); font-size: 12.5px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 12.5px; }
.hint { margin: 0; color: var(--muted); font-size: 12.5px; }

input[type=search], select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

.lists { display: flex; flex-direction: column; gap: 2px; }
.list-row { display: grid; grid-template-columns: 18px 14px 1fr auto; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; user-select: none; }
.list-row:hover { background: var(--soft); }
.list-row input { margin: 0; accent-color: var(--accent); }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(0,0,0,.15); }
.list-row .n { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.list-row.off .name, .list-row.off .dot { opacity: .4; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip .c { color: var(--muted); margin-left: 4px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] .c { color: inherit; opacity: .75; }

.toggles { gap: 6px; }
.toggles label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggles input { accent-color: var(--accent); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 12px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--accent); }
.icon-btn { border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }

.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--soft); }

/* Попап точки */
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content { margin: 12px 14px; width: 260px !important; font: 13.5px/1.4 var(--sans); color: #18201D; }
.pop img { width: 100%; height: 150px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 8px; background: #EAEFEB; }
.pop h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; line-height: 1.3; }
.pop .where { color: #5B6863; margin: 0 0 8px; }
.pop .note { margin: 0 0 8px; font-style: italic; }
.pop .row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.pop .tag { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: #DDEDE4; }
.pop .lst { font-size: 11.5px; padding: 1px 8px; border-radius: 4px; border: 1px solid; }
.pop .actions { display: flex; gap: 8px; }
.pop .actions a { flex: 1; text-align: center; padding: 7px 8px; border-radius: 7px; text-decoration: none; font-weight: 500; }
.pop .actions a.primary { background: #2E6A4E; color: #fff; }
.pop .actions a.secondary { border: 1px solid #DDE3DF; color: #18201D; }

/* Кластери в кольорах проєкту */
.cluster { display: grid; place-items: center; border-radius: 50%; background: rgba(46,106,78,.18); }
.cluster span { display: grid; place-items: center; width: calc(100% - 8px); height: calc(100% - 8px); border-radius: 50%; background: #2E6A4E; color: #fff; font: 600 12px var(--sans); font-variant-numeric: tabular-nums; }

.only-mobile { display: none; }
.fab { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 900; border: 0; border-radius: 999px; padding: 10px 18px; background: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.2); cursor: pointer; }

@media (max-width: 760px) {
  .only-mobile { display: inline-block; }
  .panel { position: fixed; inset: auto 0 0 0; width: auto; height: 78%; border-right: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px rgba(0,0,0,.18); transform: translateY(105%); transition: transform .25s ease; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .panel.open { transform: none; }
}
@media (prefers-reduced-motion: reduce) { .panel { transition: none; } }

/* Піни */

/* Вкладки панелі і список точок */
.ptabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.ptab { border: 0; background: none; padding: 10px 4px; margin-right: 12px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.ptab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.ptab span { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 400; }
.search { margin: 12px 16px 0; width: auto !important; }
.panel-body { padding-top: 12px; }
.places { flex: 1; overflow-y: auto; padding: 8px 8px 24px; }
.place { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 7px 8px; cursor: pointer; }
.place:hover, .place.active { background: var(--soft); }
.place .dot { width: 12px; height: 12px; }
.place .t { min-width: 0; }
.place .t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place .t small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place img { width: 40px; height: 30px; object-fit: cover; border-radius: 4px; }
.places .empty { color: var(--muted); padding: 24px 8px; text-align: center; }
.region-head { position: sticky; top: -8px; background: var(--surface); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 10px 8px 4px; display: flex; justify-content: space-between; }
.edit-link { display: inline-block; margin-top: 6px; font-size: 12.5px; color: var(--accent); text-decoration: none; font-weight: 500; }
.pop a.edit { display: block; margin-top: 8px; text-align: center; font-size: 12.5px; color: #2E6A4E; text-decoration: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stars { color: #B7791F; font-weight: 600; }
.closed-s { color: #B3261E; }
.pop .credit { margin: -4px 0 8px; font-size: 11px; color: #5B6863; }
.pop .closed { display: inline-block; margin: 0 0 8px; padding: 2px 8px; border-radius: 4px; background: #FBE3E1; color: #B3261E; font-weight: 600; font-size: 12px; }
.pop .where .stars { font-weight: 600; }
.pop .visited-note { display: inline-block; margin: 0 0 8px 6px; padding: 2px 8px; border-radius: 4px; background: #DDEDE4; color: #2E6A4E; font-weight: 600; font-size: 12px; }
.pop .tag.main { background: #2E6A4E; color: #fff; font-weight: 600; }
.vis-mark { color: var(--accent); }
.place .mt { font-weight: 600; color: var(--ink); }
.pop .credit a { color: inherit; }

/* Піни з іконками (як у списках Google Maps) */
.pin { position: relative; width: 34px; height: 34px; border-radius: 50%; padding: 1px; background: var(--ring, #2E6A4E); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin > span { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; background: #fff; font-size: 18px; line-height: 1; }
.pin.abandoned { background: repeating-conic-gradient(#18201D 0 8deg, #fff 8deg 16deg); }
.pin.visited > span { filter: grayscale(.6); opacity: .85; }
.pin > b { position: absolute; right: -4px; bottom: -4px; width: 15px; height: 15px; border-radius: 50%; background: #2E6A4E; color: #fff; font: 700 9px/15px var(--sans); text-align: center; border: 1.5px solid #fff; }
.dot.ico { width: 20px; height: 20px; border: 2px solid var(--ring); background: #fff; display: grid; place-items: center; font-size: 11px; line-height: 1; }
.list-row { grid-template-columns: 18px 20px 1fr auto; }
.place { grid-template-columns: 20px 1fr auto; }
#map.far .pin { transform: scale(.78); }
#map.farther .pin { transform: scale(.6); }
#map.far .cluster { transform: scale(.85); }
#map.farther .cluster { transform: scale(.7); }
.pop .ph-empty { height: 96px; border-radius: 6px; margin-bottom: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: color-mix(in srgb, var(--ring) 16%, #F1F4F2); }
.pop .ph-empty span { font-size: 34px; line-height: 1; }
.pop .ph-empty small { color: #5B6863; font-size: 11.5px; }
.place .thumb-empty { width: 40px; height: 30px; border-radius: 4px; display: grid; place-items: center; font-size: 15px; background: color-mix(in srgb, var(--ring) 22%, var(--soft)); }
.pop .vis-btn { display: block; width: 100%; margin: 0 0 8px; padding: 6px 8px; border-radius: 7px; border: 1px dashed #2E6A4E; background: #fff; color: #2E6A4E; font: 600 12.5px var(--sans); cursor: pointer; }
.pop .vis-btn.on { border-style: solid; background: #DDEDE4; }
.pop .vis-btn:disabled { opacity: .6; cursor: default; }
