:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --text: #1d1f24;
  --muted: #6b6f78;
  --line: #e2dfd6;
  --accent: #e5484d;
  --accent-text: #ffffff;
  --focus: #0090ff;
  --shadow: 0 8px 28px rgba(20, 20, 30, .18);
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #16181c;
    --surface: #1f2228;
    --surface-2: #2a2e36;
    --text: #eceef2;
    --muted: #9ba1ad;
    --line: #343944;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

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

/* Верхня панель поверх карти */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); padding: 8px 14px 8px 8px; border-radius: 999px;
  font-weight: 700; font-size: 18px; box-shadow: var(--shadow);
}
.logo {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-weight: 800;
}
.chip {
  border: 0; background: var(--surface); padding: 10px 14px; border-radius: 999px;
  box-shadow: var(--shadow); cursor: pointer; max-width: 55vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #8b8d98; }
.chip.verified .dot { background: #30a46c; }

/* Кнопка «+» */
.fab {
  position: fixed; z-index: 5; right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  width: 62px; height: 62px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-text); font-size: 34px; line-height: 1;
  box-shadow: var(--shadow); cursor: pointer;
}
.fab.cancel { background: var(--surface); color: var(--text); font-size: 28px; }

.hint {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 66px);
  background: var(--surface); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow);
  max-width: calc(100vw - 28px); display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}

/* Нижня панель / бічна панель на десктопі */
.sheet {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0;
  max-height: 72vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
}
@media (min-width: 760px) {
  .sheet {
    left: 14px; right: auto; top: 76px; bottom: 14px; width: 400px; max-height: none;
    border-radius: var(--radius);
  }
}
.sheet-close {
  position: sticky; top: 0; float: right; z-index: 1;
  border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 50%;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.sheet h2 { font-size: 20px; margin: 4px 44px 6px 0; }
.sheet h3 { font-size: 15px; margin: 18px 0 8px; }
.meta { color: var(--muted); font-size: 14px; margin: 2px 0; }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; color: #fff;
  font-size: 13px; font-weight: 600;
}
.photos { display: flex; gap: 8px; overflow-x: auto; margin: 12px 0; padding-bottom: 4px; }
.photos img { height: 120px; border-radius: 10px; flex: none; background: var(--surface-2); }
.desc { white-space: pre-wrap; line-height: 1.45; }

.votes { display: flex; gap: 8px; margin-top: 14px; }
.votes .btn { flex: 1; }
.btn {
  border: 1px solid var(--line); background: var(--surface-2); padding: 11px 14px;
  border-radius: 12px; cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.on { outline: 2px solid var(--focus); outline-offset: -2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { padding: 7px 10px; font-size: 14px; }
.note { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 14px; color: var(--muted); margin-top: 10px; }

.comments { list-style: none; padding: 0; margin: 0; }
.comments li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.comments b { font-weight: 600; }
.comments .when { color: var(--muted); font-size: 12px; margin-left: 6px; }

.near { list-style: none; padding: 0; margin: 6px 0 0; }
.near li {
  display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px;
  background: var(--surface-2); margin-bottom: 6px; cursor: pointer;
}
.near img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; }
.form label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; }
.form input:not([type=checkbox]), .form select, .form textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 11px 12px; font-weight: 400;
}
.form textarea { min-height: 80px; resize: vertical; }
.previews { display: flex; gap: 6px; flex-wrap: wrap; }
.previews img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; margin: 0; }
.err { color: var(--accent); margin: 0; font-size: 14px; }

.dlg {
  border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text);
  width: min(420px, calc(100vw - 24px)); padding: 16px; box-shadow: var(--shadow);
}
.dlg::backdrop { background: rgba(0, 0, 0, .4); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.tabs { display: flex; gap: 6px; }
.tab { border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--surface-2); color: var(--text); }
.icon-btn { border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 50%; font-size: 22px; cursor: pointer; }

.toast {
  position: fixed; z-index: 10; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow); font-size: 14px;
}

.pick-marker {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

/* Елементи MapLibre не під верхньою панеллю */
.maplibregl-ctrl-top-right { top: calc(env(safe-area-inset-top, 0px) + 60px); }
.maplibregl-ctrl-bottom-right { bottom: calc(env(safe-area-inset-bottom, 0px) + 100px); }
.maplibregl-ctrl-group { background: var(--surface); }
.maplibregl-ctrl-group button + button { border-top-color: var(--line); }
@media (prefers-color-scheme: dark) {
  .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
  .maplibregl-ctrl-attrib { background: rgba(31, 34, 40, .8) !important; color: var(--muted); }
  .maplibregl-ctrl-attrib a { color: var(--muted); }
}
