:root {
  --paper: #f7f4ee;
  --card: #ffffff;
  --ink: #1f1d1a;
  --muted: #6f6a62;
  --line: #e6e0d5;
  --accent: #1f1d1a;
  --danger: #c0392b;
  --like: #e0475f;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(31, 29, 26, .16);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}

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

#map { position: fixed; inset: 0; z-index: 0; background: #ece7dd; }
.leaflet-control-attribution { font-size: 10px; }

/* ---------- верхняя панель ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 8px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  font-family: Georgia, "Times New Roman", serif; font-style: italic;
  font-size: 26px; font-weight: 700; letter-spacing: -.5px;
  background: rgba(247, 244, 238, .92); padding: 4px 14px 6px; border-radius: 999px;
  box-shadow: var(--shadow);
}
.beta {
  font: 600 10px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-style: normal; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); vertical-align: middle;
}
.pill {
  background: var(--card); padding: 9px 16px; border-radius: 999px;
  font-weight: 600; box-shadow: var(--shadow); max-width: 50vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- категории ---------- */
.chips {
  position: fixed; top: calc(58px + env(safe-area-inset-top, 0px)); left: 0; right: 0; z-index: 500;
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 14px 10px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: var(--card); padding: 7px 13px; border-radius: 999px;
  font-size: 14px; box-shadow: 0 2px 10px rgba(31, 29, 26, .12);
  border: 2px solid transparent;
}
.chip.active { border-color: var(--c, var(--ink)); background: color-mix(in srgb, var(--c, #000) 12%, white); font-weight: 600; }

/* ---------- кнопки внизу ---------- */
.fab-row {
  position: fixed; left: 0; right: 0; bottom: calc(18px + var(--safe-bottom)); z-index: 500;
  display: flex; justify-content: center; gap: 10px; padding: 0 14px; pointer-events: none;
}
.fab { pointer-events: auto; padding: 14px 20px; border-radius: 999px; font-weight: 700; font-size: 16px; box-shadow: var(--shadow); }
.primary { background: var(--accent); color: #fff; }
.secondary { background: var(--card); color: var(--ink); }
.ghost { background: transparent; color: var(--muted); }
.danger { background: transparent; color: var(--danger); }
.round {
  position: fixed; right: 14px; bottom: calc(86px + var(--safe-bottom)); z-index: 500;
  width: 46px; height: 46px; border-radius: 50%; background: var(--card);
  font-size: 22px; box-shadow: var(--shadow);
}

/* ---------- метки ---------- */
.pin { background: none; border: 0; }
.pin-dot {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px;
  background: var(--c); border: 3px solid #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
  transition: transform .15s;
}
.pin-dot.mine { outline: 3px solid var(--ink); outline-offset: 1px; }
.pin-dot.new { animation: pop .6s ease-out; }
.pin:hover .pin-dot { transform: scale(1.12); }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2d7dd2; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(45, 125, 210, .25); }

/* ---------- выбор точки ---------- */
.picker-pin {
  position: fixed; left: 50%; top: 50%; z-index: 600;
  transform: translate(-50%, -100%); font-size: 44px; line-height: 1;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .3)); pointer-events: none;
}
.picker-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(14px + var(--safe-bottom)); z-index: 600;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
  max-width: 520px; margin: 0 auto;
}
.picker-bar p { margin: 0 0 10px; text-align: center; color: var(--muted); }
.picker-actions { display: flex; gap: 8px; }
.picker-actions button { flex: 1; padding: 12px 8px; border-radius: 12px; font-weight: 600; }
.picker-actions .secondary { border: 1px solid var(--line); }
body.picking .fab-row, body.picking .chips, body.picking #btn-locate { display: none; }

/* ---------- нижняя шторка / боковая панель ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 700;
  max-height: 78vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--paper); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
  padding: 22px 18px calc(22px + var(--safe-bottom));
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-close {
  position: sticky; top: 0; float: right; margin: -8px -4px 0 8px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; background: var(--line); font-size: 22px; line-height: 1;
}
@media (min-width: 760px) {
  .sheet {
    top: 0; right: auto; width: 400px; max-height: none; border-radius: 0 22px 22px 0;
    padding-top: calc(86px + env(safe-area-inset-top, 0px));
  }
  .topbar { z-index: 800; }
  body.sheet-open .chips { left: 400px; }
}

.sheet h2 { margin: 2px 0 8px; font-size: 22px; line-height: 1.2; }
.sheet h3 { margin: 18px 0 8px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* карточка места */
.place-photo { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 14px; margin-bottom: 12px; background: var(--line); }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: color-mix(in srgb, var(--c) 14%, white); color: color-mix(in srgb, var(--c) 75%, black); }
.desc { white-space: pre-wrap; line-height: 1.5; margin: 6px 0 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions button { padding: 10px 16px; border-radius: 999px; font-weight: 600; background: var(--card); border: 1px solid var(--line); }
.actions .like.on { background: var(--like); border-color: var(--like); color: #fff; }
.actions .danger { border-color: transparent; }

/* формы */
.form label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 14px; }
.form input[type=text], .form input[type=email], .form input[type=password], .form textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font: inherit; font-size: 16px; color: var(--ink);
}
.form textarea { resize: vertical; min-height: 80px; }
.form input:focus, .form textarea:focus { outline: 2px solid var(--ink); outline-offset: 0; }
.cat-pick { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 6px 0 0; }
.cat-pick legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.cat-pick input { position: absolute; opacity: 0; pointer-events: none; }
.cat-pick span { display: inline-block; padding: 8px 12px; border-radius: 999px; background: var(--card); border: 2px solid var(--line); font-size: 14px; }
.cat-pick input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); font-weight: 600; }
.cat-pick input:focus-visible + span { outline: 2px solid var(--ink); }
.photo-btn { display: flex !important; align-items: center; gap: 10px; padding: 12px 14px; border: 1px dashed var(--muted); border-radius: 12px; background: var(--card); font-weight: 500 !important; cursor: pointer; }
.photo-btn input { display: none; }
.photo-preview { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; margin-top: 8px; }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 400 !important; line-height: 1.4; }
.check input { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.wide { width: 100%; padding: 14px; border-radius: 14px; font-weight: 700; font-size: 16px; margin-top: 12px; }
.wide:disabled { opacity: .6; }
.tabs { display: flex; background: var(--line); border-radius: 12px; padding: 4px; margin: 10px 0 4px; }
.tabs button { flex: 1; padding: 9px; border-radius: 9px; background: transparent; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); }
.link { background: none; padding: 0; color: var(--ink); text-decoration: underline; }
a { color: inherit; }

/* рейтинг */
.board { list-style: none; padding: 0; margin: 10px 0 0; }
.board li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--card); margin-bottom: 6px; }
.board li.me { outline: 2px solid var(--ink); }
.board .rank { width: 28px; text-align: center; font-weight: 700; font-size: 18px; }
.board .who { flex: 1; min-width: 0; }
.board .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .score { font-weight: 800; font-size: 18px; }
.stats { display: flex; gap: 10px; margin: 12px 0; }
.stat { flex: 1; background: var(--card); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.mylist { list-style: none; padding: 0; margin: 0; }
.mylist li button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--card); border-radius: 12px; margin-bottom: 6px; }

/* тост */
.toast {
  position: fixed; left: 50%; top: calc(110px + env(safe-area-inset-top, 0px)); z-index: 900;
  transform: translateX(-50%); max-width: calc(100vw - 28px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow); text-align: center;
  animation: fade .25s ease-out;
}
@keyframes fade { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 759px) {
  .leaflet-control-zoom { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
