:root {
  --bg: #f7f5ef;
  --surface: rgba(255, 255, 255, 0.94);
  --text: #1d2923;
  --muted: #6f7c75;
  --green: #2f7d58;
  --green-dark: #1f6243;
  --blue: #4676d7;
  --yellow: #e0a22e;
  --danger: #b63c3c;
  --border: rgba(29, 41, 35, 0.12);
  --shadow: 0 12px 32px rgba(24, 48, 35, 0.16);
  --tg-safe-top: var(--tg-content-safe-area-inset-top, 0px);
  --tg-safe-bottom: var(--tg-content-safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  gap: 14px;
  text-align: center;
  background: linear-gradient(150deg, #f7f5ef, #e8f1e7);
}

.loading-mark {
  font-size: 42px;
  animation: breathe 1.6s ease-in-out infinite;
}

@keyframes breathe {
  50% { transform: scale(1.12) rotate(-4deg); }
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  padding-top: var(--tg-safe-top);
}

.topbar {
  position: absolute;
  z-index: 500;
  top: calc(12px + var(--tg-safe-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 12px 11px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 21px;
}

h2 {
  font-size: 25px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.avatar-button,
.close-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
}

.icon-button {
  color: var(--green-dark);
  background: #e5efe8;
  font-size: 24px;
}

.avatar-button {
  color: white;
  background: var(--green);
  font-weight: 800;
}

.filters {
  position: absolute;
  z-index: 500;
  top: calc(92px + var(--tg-safe-top));
  left: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.87);
  box-shadow: 0 5px 16px rgba(24, 48, 35, 0.1);
  cursor: pointer;
  opacity: 0.58;
  backdrop-filter: blur(12px);
}

.filter.active {
  opacity: 1;
  border-color: rgba(47, 125, 88, 0.32);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.green { background: var(--green); }
.blue { background: var(--blue); }
.yellow { background: var(--yellow); }

#map {
  width: 100%;
  height: 100%;
  background: #dfe9df;
}

.leaflet-control-zoom {
  display: none;
}

.leaflet-control-attribution {
  margin-bottom: calc(2px + var(--tg-safe-bottom)) !important;
  font-size: 9px !important;
}

.map-marker {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid white;
  border-radius: 13px 13px 13px 4px;
  box-shadow: 0 5px 14px rgba(24, 48, 35, 0.28);
  color: white;
  font-size: 19px;
  transform: rotate(-45deg);
}

.map-marker span {
  transform: rotate(45deg);
}

.map-marker.place { background: var(--green); }
.map-marker.walk { background: var(--blue); }
.map-marker.event { background: var(--yellow); }
.map-marker.user { background: #23372d; border-radius: 50%; }

.leaflet-popup-content-wrapper {
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  width: 235px !important;
  margin: 16px !important;
}

.popup-tag {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.popup-title {
  margin: 0 0 7px;
  font-size: 18px;
}

.popup-meta {
  margin: 4px 0;
  color: var(--muted);
  line-height: 1.35;
}

.popup-note {
  margin: 9px 0;
  padding: 9px;
  border-radius: 10px;
  background: #f1f5f1;
}

.popup-actions {
  display: flex;
  gap: 7px;
  margin-top: 12px;
}

.popup-actions button,
.popup-actions a {
  flex: 1;
  padding: 9px;
  border: 0;
  border-radius: 10px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.popup-primary {
  color: white;
  background: var(--green);
}

.popup-secondary {
  color: var(--text);
  background: #edf0ed;
}

.legend-card {
  position: absolute;
  z-index: 500;
  left: 14px;
  bottom: calc(82px + var(--tg-safe-bottom));
  display: flex;
  max-width: min(320px, calc(100% - 150px));
  flex-direction: column;
  gap: 2px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.legend-card strong { font-size: 13px; }
.legend-card span { color: var(--muted); font-size: 11px; }

.primary-fab {
  position: absolute;
  z-index: 500;
  right: 14px;
  bottom: calc(22px + var(--tg-safe-bottom));
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 17px;
  color: white;
  background: var(--green);
  box-shadow: 0 10px 26px rgba(36, 106, 73, 0.35);
  font-weight: 800;
  cursor: pointer;
}

.sheet-dialog {
  width: min(100%, 560px);
  max-width: none;
  max-height: 92vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 26px 26px 0 0;
  color: var(--text);
  background: transparent;
}

.sheet-dialog::backdrop {
  background: rgba(12, 24, 17, 0.45);
  backdrop-filter: blur(3px);
}

.sheet {
  display: flex;
  max-height: 92vh;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 10px 20px calc(24px + var(--tg-safe-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--bg);
}

.compact-sheet { min-height: 360px; }

.sheet-handle {
  width: 45px;
  height: 5px;
  margin: 0 auto 2px;
  border-radius: 999px;
  background: #ccd3ce;
}

.sheet-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.close-button {
  background: #e6e9e6;
  font-size: 26px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #415048;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  color: var(--text);
  background: white;
}

input,
select {
  height: 48px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 88, 0.12);
}

.two-columns {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 10px;
}

.rules-check {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: start;
  font-weight: 500;
  line-height: 1.35;
}

.rules-check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--green);
}

.primary-button,
.danger-button {
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.primary-button { background: var(--green); }
.danger-button { background: var(--danger); }

.walk-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.walk-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: white;
}

.walk-card h3 {
  margin: 0 0 6px;
}

.walk-card p {
  margin: 4px 0;
  color: var(--muted);
}

.status-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green-dark);
  background: #e5efe8;
  font-size: 12px;
  font-weight: 700;
}

.website-card {
  width: min(92vw, 440px);
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px 24px;
  border: 1px solid rgba(28, 50, 39, 0.12);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 50px rgba(28, 50, 39, 0.12);
  text-align: center;
}

.website-card strong {
  font-size: clamp(1.45rem, 5vw, 2rem);
}

.website-card span,
.website-card small {
  line-height: 1.5;
  color: var(--muted);
}

.telegram-login {
  min-height: 44px;
}

.website-primary,
.website-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
}

.website-primary {
  color: #fff;
  background: var(--ink);
}

.website-secondary {
  color: var(--ink);
  border: 1px solid rgba(28, 50, 39, 0.2);
  background: #fff;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.card-actions button {
  flex: 1;
  padding: 9px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.empty-state {
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 2000;
  left: 50%;
  bottom: calc(18px + var(--tg-safe-bottom));
  max-width: calc(100% - 28px);
  padding: 12px 16px;
  border-radius: 13px;
  color: white;
  background: #23372d;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 700px) {
  .topbar,
  .filters { max-width: 500px; }
  .legend-card { bottom: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
