:root {
  --bg: #f7f5ef;
  --surface: rgba(255, 255, 255, 0.94);
  --text: #1d2923;
  --muted: #6f7c75;
  --green: #2f7d58;
  --green-dark: #1f6243;
  --blue: #4676d7;
  --yellow: #e0a22e;
  --purple: #7048bd;
  --danger: #b63c3c;
  --border: rgba(29, 41, 35, 0.12);
  --border-strong: rgba(29, 41, 35, 0.2);
  --surface-solid: #ffffff;
  --surface-soft: #f0f4f1;
  --control-height: 48px;
  --control-radius: 14px;
  --shadow: 0 12px 32px rgba(24, 48, 35, 0.16);
  --shadow-soft: 0 5px 16px rgba(24, 48, 35, 0.1);
  --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 {
  appearance: none;
  -webkit-appearance: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 125, 88, 0.24);
  outline-offset: 2px;
}

.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;
}

.loading > span {
  max-width: min(86vw, 420px);
  color: var(--muted);
  line-height: 1.45;
}

@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: var(--surface-soft);
  font-size: 24px;
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.admin-button { position: relative; }
.profile-button { position: relative; }
.admin-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid white;
  border-radius: 999px;
  color: white;
  background: var(--danger);
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
}

.event-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid white;
  border-radius: 999px;
  color: #342600;
  background: var(--yellow);
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
}

.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); }
.gold { background: #d9a600; }
.purple { background: var(--purple); }

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

#mapView {
  width: 100%;
  height: 100%;
}

.map-toolbar {
  position: absolute;
  z-index: 510;
  top: calc(138px + var(--tg-safe-top));
  left: 14px;
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 5px 16px rgba(24, 48, 35, 0.1);
}

.map-toolbar button {
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.map-toolbar button.active {
  color: white;
  background: var(--green);
}

.map-list-view {
  height: 100%;
  padding: calc(190px + var(--tg-safe-top)) 14px calc(100px + var(--tg-safe-bottom));
  overflow-y: auto;
  background: var(--surface-soft);
}

.map-cluster {
  --cluster-accent: var(--green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  height: 42px;
  gap: 5px;
  padding: 0 10px;
  border: 3px solid white;
  border-radius: 15px 15px 15px 5px;
  color: white;
  background: var(--cluster-accent);
  box-shadow: 0 5px 16px rgba(24, 48, 35, 0.3);
  font-size: 14px;
  transform: rotate(-4deg);
}

.map-cluster > span,
.map-cluster > strong {
  line-height: 1;
  transform: rotate(4deg);
}

.map-cluster.place-favorite {
  border-color: #ffd34e;
  box-shadow: 0 0 0 3px rgba(255, 211, 78, 0.35), 0 5px 16px rgba(24, 48, 35, 0.3);
}

.map-cluster.walk { --cluster-accent: var(--blue); }
.map-cluster.event { --cluster-accent: var(--yellow); color: #3d2f08; }

.cluster-list {
  display: grid;
  max-height: min(var(--cluster-list-max-height, 300px), 38dvh);
  min-height: 0;
  gap: 6px;
  overflow-y: auto;
  padding-right: 3px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.cluster-item-button {
  display: grid;
  width: 100%;
  min-height: 44px;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.cluster-item-button small {
  color: var(--muted);
}

.notification-button { position: relative; }
.wizard-progress { margin: 2px 0 12px; color: var(--muted); font-size: 13px; }
.wizard-step { display: grid; gap: 14px; }
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.choice-grid legend { padding: 0 5px; color: var(--muted); }
.choice-grid label {
  display: flex;
  min-height: 44px;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  font-weight: 600;
}
.choice-grid input { flex: 0 0 auto; }
.form-error { margin: 0; color: var(--danger); }
.settings-grid { display: grid; gap: 10px; }
.mini-toggle {
  display: inline-flex;
  min-height: 44px;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 650;
}
.member-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 8px 0; }
.member-chip { display: inline-flex; gap: 5px; padding: 6px 8px; border-radius: 999px; background: var(--surface-soft); }
.member-chip button { padding: 0; border: 0; background: transparent; cursor: pointer; }
.unread-card { border-color: rgba(47, 125, 88, 0.6); background: var(--surface-soft); }

.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.place-favorite {
  background: var(--green);
  border-color: #ffd34e;
  box-shadow: 0 0 0 4px rgba(255, 211, 78, 0.42), 0 5px 14px rgba(24, 48, 35, 0.28);
}
.map-marker.walk { background: var(--blue); }
.map-marker.event { background: var(--yellow); }
.map-marker.user,
.map-marker.user-current,
.map-marker.user-local {
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
}

.map-marker.user { background: var(--purple); }
.map-marker.user-current { background: #3e227a; }
.map-marker.user-local { background: #23372d; }

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

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

.cluster-popup .leaflet-popup-content {
  width: min(300px, calc(100vw - 64px)) !important;
  max-height: min(var(--cluster-popup-max-height, 470px), 62dvh);
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.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;
  overflow-wrap: anywhere;
}

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

.popup-note {
  margin: 9px 0;
  padding: 9px;
  border-radius: 10px;
  background: var(--surface-soft);
}

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

.popup-actions button,
.popup-actions a {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  flex: 1 1 108px;
  padding: 9px;
  border: 0;
  border-radius: 12px;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  white-space: normal;
  cursor: pointer;
}

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

.popup-secondary {
  color: var(--text);
  background: var(--surface-soft);
}

.map-warning {
  position: absolute;
  z-index: 520;
  top: calc(144px + var(--tg-safe-top));
  left: 50%;
  width: min(430px, calc(100% - 28px));
  padding: 12px 46px 12px 14px;
  border: 1px solid rgba(170, 103, 22, 0.24);
  border-radius: 14px;
  background: rgba(255, 248, 229, 0.96);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.map-warning strong,
.map-warning span {
  display: block;
}

.map-warning span {
  margin-top: 2px;
  color: #765623;
  font-size: 12px;
}

.map-warning button {
  position: absolute;
  top: 9px;
  right: 9px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: #f2dfb6;
  cursor: pointer;
}

.legend-card {
  position: absolute;
  z-index: 500;
  top: calc(190px + var(--tg-safe-top));
  left: 14px;
  display: inline-flex;
  max-width: calc(100% - 28px);
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 5px 16px rgba(24, 48, 35, 0.1);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.legend-card strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-actions {
  position: absolute;
  z-index: 500;
  right: 14px;
  bottom: calc(22px + var(--tg-safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.place-picker {
  position: absolute;
  z-index: 650;
  inset: 0;
  pointer-events: none;
}

.place-picker[hidden] { display: none; }
.picker-mode .topbar,
.picker-mode .filters,
.picker-mode .legend-card,
.picker-mode > .map-actions,
.picker-mode .map-warning { display: none; }
.place-picker .picker-instruction,
.place-picker .picker-actions { pointer-events: auto; }
.picker-instruction {
  position: absolute;
  top: calc(16px + var(--tg-safe-top));
  left: 50%;
  display: flex;
  width: min(92%, 420px);
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translateX(-50%);
}
.picker-instruction span { color: var(--muted); font-size: 12px; }
.map-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  border: 3px solid white;
  border-radius: 50%;
  background: rgba(47, 125, 88, 0.18);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
}
.map-crosshair::before,
.map-crosshair::after {
  position: absolute;
  content: "";
  background: var(--green-dark);
}
.map-crosshair::before { top: 21px; left: -9px; width: 60px; height: 3px; }
.map-crosshair::after { top: -9px; left: 21px; width: 3px; height: 60px; }
.map-crosshair span { position: absolute; inset: 17px; border-radius: 50%; background: var(--green-dark); }
.picker-actions {
  position: absolute;
  right: 14px;
  bottom: calc(18px + var(--tg-safe-bottom));
  left: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.picker-actions .primary-fab { grid-column: 1 / -1; }
.selected-place-preview {
  display: flex;
  min-height: 76px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 12px 14px;
  border: 1px dashed rgba(47, 125, 88, 0.45);
  border-radius: 14px;
  background: var(--surface-soft);
}
.selected-place-preview span { color: var(--muted); font-size: 12px; }
.nearby-warning {
  padding: 10px 12px;
  border: 1px solid #e1b55a;
  border-radius: 12px;
  color: #694a0b;
  background: #fff5d9;
  font-size: 12px;
}
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.primary-fab,
.event-fab,
.secondary-fab {
  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;
}

.event-fab {
  min-height: 42px;
  color: var(--text);
  background: #f2c94c;
  box-shadow: 0 8px 20px rgba(132, 101, 10, 0.24);
}

.secondary-fab {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid rgba(47, 125, 88, 0.25);
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 7px 18px rgba(24, 48, 35, 0.16);
}

.chat-sheet { height: min(78vh, 680px); }
.chat-messages { display: flex; flex: 1; flex-direction: column; gap: 8px; overflow-y: auto; }
.chat-message { display: flex; max-width: 88%; flex-direction: column; gap: 3px; padding: 9px 11px; border-radius: 13px; background: var(--surface-solid); }
.chat-message span { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message small { color: var(--muted); font-size: 10px; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.chat-form .primary-button { width: auto; }
.chat-message-actions { display: flex; justify-content: flex-end; }
.chat-message-actions button { border: 0; color: var(--muted); background: transparent; font-size: 11px; }

.event-free-check {
  align-self: end;
  min-height: 44px;
}

.sheet-dialog {
  width: min(100%, 560px);
  max-width: none;
  max-height: 92dvh;
  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: 92dvh;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 20px calc(24px + var(--tg-safe-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--bg);
  overscroll-behavior: contain;
  scroll-padding-bottom: calc(90px + var(--tg-safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.sheet > hr {
  width: 100%;
  height: 1px;
  margin: 7px 0;
  border: 0;
  background: var(--border);
}

.sheet > * {
  min-width: 0;
}

.sheet h3,
.sheet h4 {
  margin: 2px 0 0;
  line-height: 1.25;
}

#myWalksDialog .sheet {
  gap: 12px;
}

#myWalksDialog .sheet > h3 {
  margin-top: 2px;
  font-size: 20px;
}

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

.create-type-grid {
  display: grid;
  gap: 10px;
}

.create-type-button {
  --create-accent: var(--green);
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  min-height: 68px;
  padding: 10px 14px;
  border: 1px solid rgba(47, 125, 88, 0.26);
  border-color: color-mix(in srgb, var(--create-accent) 34%, transparent);
  border-radius: 17px;
  background: var(--surface-solid);
  text-align: left;
  cursor: pointer;
}

.create-type-button > span:last-child {
  display: grid;
  gap: 3px;
}

.create-type-button strong { font-size: 16px; }
.create-type-button small { color: var(--muted); font-size: 12px; }

.create-type-marker {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid white;
  border-radius: 13px 13px 13px 4px;
  color: white;
  background: var(--create-accent);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--create-accent) 32%, transparent);
  font-size: 18px;
  transform: rotate(-45deg);
}

.create-type-marker > span {
  display: block;
  line-height: 1;
  transform: rotate(45deg);
}

.create-type-walk { --create-accent: var(--blue); border-color: rgba(70, 118, 215, 0.35); }
.create-type-place { --create-accent: var(--green); border-color: rgba(47, 125, 88, 0.35); }
.create-type-event { --create-accent: var(--yellow); border-color: rgba(224, 162, 46, 0.42); }

.create-type-walk .create-type-marker,
.create-type-place .create-type-marker,
.create-type-event .create-type-marker {
  padding: 0;
}

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

.sheet-title-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-title-row h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sheet-title-row .close-button {
  flex: 0 0 42px;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--text);
  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: var(--surface-solid);
}

input,
select {
  min-width: 0;
  height: var(--control-height);
  padding: 0 12px;
}

select {
  text-overflow: ellipsis;
}

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;
  min-height: var(--control-height);
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--surface-solid);
  font-weight: 600;
  line-height: 1.35;
}

input[type="checkbox"] {
  display: grid;
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  place-content: center;
  border: 2px solid #9fada5;
  border-radius: 7px;
  background: var(--surface-solid);
  cursor: pointer;
}

input[type="checkbox"]::before {
  content: "✓";
  color: white;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  transform: scale(0);
  transition: transform 120ms ease;
}

input[type="checkbox"]:checked {
  border-color: var(--green);
  background: var(--green);
}

input[type="checkbox"]:checked::before {
  transform: scale(1);
}

.primary-button,
.secondary-button,
.danger-link,
.danger-button {
  display: inline-flex;
  min-height: var(--control-height);
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.primary-button { background: var(--green); }
.secondary-button {
  border-color: rgba(47, 125, 88, 0.22);
  color: var(--green-dark);
  background: var(--surface-soft);
}
.danger-button { background: var(--danger); }
.danger-link {
  border-color: rgba(182, 60, 60, 0.18) !important;
  color: #8f3030 !important;
  background: #fbefef !important;
}

.primary-button,
.danger-button {
  color: white;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active,
.danger-link:active,
.card-actions button:active,
.friend-search-row button:active {
  transform: translateY(1px);
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.privacy-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.location-share-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 2px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
}

.location-share-panel h3 {
  margin: 0;
  font-size: 17px;
}

.location-share-panel small {
  color: var(--muted);
  line-height: 1.4;
}

.location-share-panel a {
  color: var(--green-dark);
}

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

.friend-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, auto);
  gap: 8px;
  margin-bottom: 12px;
}

.friend-search-row > button {
  min-width: 104px;
}

.friend-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.friend-card .friend-controls {
  display: grid;
  min-width: 132px;
  gap: 8px;
}

.friend-card .friend-controls > :only-child {
  grid-column: 1 / -1;
}

.friend-card p {
  margin: 4px 0 0;
}

.walk-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface-solid);
  box-shadow: 0 4px 14px rgba(24, 48, 35, 0.04);
}

.walk-card > strong,
.walk-card > span,
.walk-card h3,
.walk-card h4,
.walk-card p,
.walk-card label,
.empty-state,
.privacy-copy,
.chat-message,
.selected-place-preview {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.moderation-list,
.moderation-section {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.moderation-list {
  gap: 20px;
}

.moderation-section + .moderation-section {
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.moderation-section-title {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.moderation-section-title h3 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.moderation-count,
.moderation-kind {
  display: inline-flex;
  min-width: 28px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.moderation-kind {
  width: fit-content;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.moderation-section.complaints .moderation-count,
.moderation-kind.complaint {
  color: #8f3030;
  background: #fbefef;
}

.moderation-section.feedback .moderation-count,
.moderation-kind.feedback {
  color: #3e227a;
  background: #eee8fa;
}

.report-card > strong {
  display: block;
  margin-bottom: 7px;
}

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

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

.walk-card > .mini-toggle {
  width: 100%;
  margin-top: 12px;
}

.status-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--surface-soft);
  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: var(--surface-solid);
  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;
  border: 0;
  background: var(--text);
  cursor: pointer;
}

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

.error-card code {
  padding: 7px 10px;
  border-radius: 9px;
  color: #7f3232;
  background: #f8e8e8;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.card-actions button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border: 1px solid rgba(47, 125, 88, 0.16);
  border-radius: 12px;
  color: var(--green-dark);
  background: var(--surface-soft);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.card-actions .primary-button {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.empty-state {
  padding: 18px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--control-radius);
  color: var(--muted);
  background: var(--surface-soft);
  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);
}

/* Keep the required map attribution text, but hide Leaflet's decorative flag. */
.leaflet-attribution-flag {
  display: none !important;
}

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

@media (max-width: 380px) {
  .topbar {
    left: 8px;
    right: 8px;
    padding-left: 12px;
  }

  .topbar-actions {
    gap: 5px;
  }

  .icon-button,
  .avatar-button {
    width: 37px;
    height: 37px;
    border-radius: 12px;
  }

  h1 {
    font-size: 18px;
  }
}

@media (max-width: 699px) {
  .map-actions { max-width: calc(100% - 28px); }
  .popup-actions { flex-wrap: wrap; }
  .leaflet-popup-content { width: min(235px, calc(100vw - 86px)) !important; }
}

@media (max-width: 420px) {
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .friend-card {
    grid-template-columns: 1fr;
  }

  .friend-card .friend-controls {
    min-width: 0;
    grid-template-columns: 1fr 1fr;
  }
}

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

/* v20: clusters open below the anchor, never above it. */
.leaflet-popup.cluster-popup {
  bottom: auto !important;
  top: 16px;
  margin-bottom: 0;
}
.cluster-popup .leaflet-popup-tip-container {
  top: -19px;
  bottom: auto;
  transform: rotate(180deg);
}
.cluster-popup .leaflet-popup-content {
  max-height: var(--cluster-popup-max-height, 340px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.cluster-popup .leaflet-popup-content > :not(.cluster-list) { flex-shrink: 0; }
.cluster-popup .cluster-list { flex: 0 0 auto; max-height: var(--cluster-list-max-height, 180px); }
.cluster-popup .leaflet-popup-content-wrapper { display: flow-root; }
.topbar h1 { font-size: 18px; }
.topbar .eyebrow { display: none; }
.topbar-actions { gap: 5px; }
.map-toolbar { top: var(--toolbar-top, 82px); right: 14px; width: fit-content; max-width: calc(100% - 28px); }
.map-toolbar button { min-width: 0; padding: 10px 12px; }
.legend-card { top: var(--summary-top, 140px); pointer-events: none; }
.map-list-view { top: calc(var(--summary-top, 140px) + 48px); }
.map-actions { flex-direction: row; align-items: center; gap: 10px; }
#createMenuButton.create-compact { width: 48px; min-width: 48px; height: 48px; padding: 0; font-size: 28px; border-radius: 14px; }
#findWalkButton { min-height: 48px; padding: 12px 18px; font-size: 16px; }
.advanced-options { border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.advanced-options summary { cursor: pointer; color: var(--green-dark); font-weight: 650; overflow-wrap: anywhere; }
.advanced-options[open] > :not(summary) { margin-top: 12px; }
[data-intro-step] p { line-height: 1.5; }
[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip,
[data-theme="dark"] .sheet,
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select { background: var(--surface-solid); color: var(--text); }
[data-theme="dark"] .icon-button,
[data-theme="dark"] .close-button,
[data-theme="dark"] .secondary-button,
[data-theme="dark"] .secondary-fab,
[data-theme="dark"] .map-toolbar,
[data-theme="dark"] .filter,
[data-theme="dark"] .rules-check,
[data-theme="dark"] .choice-grid label { background: var(--surface-soft); color: var(--text); }
[data-theme="dark"] .loading { background: var(--bg); }
[data-theme="dark"] .primary-button,
[data-theme="dark"] .primary-fab,
[data-theme="dark"] .popup-primary { background: #28744f; color: #fff; }
[data-theme="dark"] { color-scheme: dark; }
@media(max-width: 370px) {
  .topbar { padding: 9px; gap: 6px; }
  .topbar h1 { font-size: 16px; }
  .topbar-actions { gap: 4px; }
  .topbar .icon-button, .topbar .avatar-button { width: 36px; height: 40px; }
  .map-toolbar button { padding: 10px; }
}
[hidden] { display: none !important; }

/* v21: individual markers share the downward placement and safe-area sizing. */
.leaflet-popup.point-popup { bottom: auto !important; top: 16px; margin-bottom: 0; }
.point-popup .leaflet-popup-tip-container { top: -19px; bottom: auto; transform: rotate(180deg); }
.point-popup .leaflet-popup-content-wrapper { display: flow-root; }
.point-popup .leaflet-popup-content {
  width: min(300px, calc(100vw - 64px)) !important;
  max-height: var(--cluster-popup-max-height, 340px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
#inviteDialog p, #guideDialog p { line-height: 1.5; overflow-wrap: anywhere; }

/* v22: readable labels and secondary copy on dark personal cards. */
[data-theme="dark"] .empty-state { color: var(--muted); background: var(--surface-soft); }
[data-theme="dark"] .event-fab { color: #342600; }

/* Universal login and install screens use the same theme tokens. */
#codeLoginForm { display:grid; gap:12px; width:100%; min-width:0; }
#codeLoginForm input { width:100%; min-width:0; box-sizing:border-box; }
#codeLoginError { color:var(--text); overflow-wrap:anywhere; }
#installAppDialog { max-width:480px; }
#installAppDialog section { padding:24px; }
