:root {
  /* Глубокий "лесной" зелёный вместо плоского Tailwind-изумруда — тот же зелёный по духу,
     но более насыщенный и "выращенный". Тёплый медовый акцент — образ нового дня/утра,
     устойчивая метафора в культуре трезвости. */
  --primary: #1F7A4D;
  --primary-dark: #145C39;
  --primary-light: #E3F1E7;
  --accent: #E8A33D;
  --accent-light: #FBEED9;
  --danger: #DC4C4C;
  --danger-light: #FBE4E4;
  --bg-color: #F6F8F3;
  --surface: #FFFFFF;
  --text-main: #1B2A22;
  --text-secondary: #57685E;
  --text-muted: #93A198;
  --border: #E3E9E1;
  --shadow-sm: 0 1px 2px 0 rgb(27 42 34 / 0.06);
  --shadow: 0 6px 16px -4px rgb(27 42 34 / 0.14);
  --shadow-lg: 0 16px 32px -8px rgb(27 42 34 / 0.20);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --font-display: 'Golos Text', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: 'Golos Text', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg-color);
  color: var(--text-main);
  height: 100vh; /* фолбэк для старых браузеров */
  height: 100dvh; /* реальная видимая высота на мобильных, без адресной строки */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.mobile-only { display: none !important; }

/* Навбар */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* Мягкое зелёное свечение за навбаром — единственный акцентный жест, "прорастание" */
.navbar::before {
  content: '';
  position: absolute; top: -60%; left: -4%;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, var(--primary-light) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
.navbar > * { position: relative; z-index: 1; }

.logo { display: flex; align-items: center; gap: 12px; }
.logo > i {
  font-size: 1.15rem; color: var(--primary);
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo h1 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; }
.logo p { font-size: 0.78rem; color: var(--text-muted); }

.nav-actions { display: flex; gap: 8px; align-items: center; }

.btn-primary {
  background: var(--primary); color: white; border: none;
  padding: 11px 22px; border-radius: var(--radius-pill);
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
  transition: all 0.2s cubic-bezier(.4,0,.2,1); display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 8px 20px -6px rgb(31 122 77 / 0.5); }

.btn-secondary {
  background: var(--surface); color: var(--text-secondary);
  border: 1.5px solid var(--border); padding: 10px 20px;
  border-radius: var(--radius-pill); font-weight: 600; cursor: pointer; transition: all 0.2s;
  font-family: var(--font-body);
}
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }

.btn-icon {
  width: 42px; height: 42px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-secondary); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary); }

.btn-danger {
  background: var(--danger-light); color: var(--danger);
  border: none; padding: 6px 12px; border-radius: 6px;
  font-size: 0.8rem; cursor: pointer; transition: all 0.2s;
}
.btn-danger:hover { background: var(--danger); color: white; }

/* Поиск — плавающая "пилюля", а не плоская панель */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  margin: 12px 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  flex-shrink: 0;
}
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.search-bar > i { color: var(--primary); }
.search-bar input {
  flex: 1; border: none; background: transparent;
  font-size: 0.95rem; outline: none; color: var(--text-main);
  font-family: var(--font-body);
}
.search-bar input::placeholder { color: var(--text-muted); }
.clear-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }
.clear-btn.hidden { display: none; }

/* Фильтры */
.filters-bar {
  display: flex; gap: 8px; padding: 2px 24px 14px;
  background: var(--surface);
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.filters-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-secondary); padding: 8px 16px;
  border-radius: var(--radius-pill); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body);
}
.filter-btn i { font-size: 0.8rem; }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 4px 12px -4px rgb(31 122 77 / 0.5); }
.filter-btn:hover:not(.active) { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary); }

/* Макет */
.app-container { display: flex; flex: 1; overflow: hidden; border-top: 1px solid var(--border); }

/* Сайдбар */
.sidebar {
  width: 380px; background: var(--bg-color);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform 0.3s ease;
}
.sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.sidebar-header h3 { font-family: var(--font-display); font-size: 0.95rem; font-weight: 700; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }

.places-list {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.places-list::-webkit-scrollbar { width: 6px; }
.places-list::-webkit-scrollbar-track { background: transparent; }
.places-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Карточка */
.place-card {
  background: var(--surface); border: 1px solid var(--border);
  padding: 16px; border-radius: var(--radius);
  cursor: pointer; transition: all 0.2s cubic-bezier(.4,0,.2,1); position: relative;
}
.place-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
.place-card.active { border-color: var(--primary); background: var(--primary-light); }

.place-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.place-card h4 { font-family: var(--font-display); font-size: 1rem; font-weight: 700; margin: 0; flex: 1; }

.category-badge {
  font-size: 0.68rem; padding: 3px 9px; border-radius: var(--radius-pill);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.category-badge.sober-bar { background: #DCEBFA; color: #1C5389; }
.category-badge.cafe { background: var(--accent-light); color: #8A5A17; }
.category-badge.coffee { background: #F5DFF6; color: #7A2C82; }
.category-badge.restaurant { background: var(--primary-light); color: var(--primary-dark); }
.category-badge.loft { background: #E4E3FA; color: #3E3B8C; }
.category-badge.activity { background: #FCE3D6; color: #9A4A20; }

.place-card .address {
  font-size: 0.85rem; color: var(--text-secondary);
  margin-bottom: 8px; display: flex; align-items: center; gap: 4px;
}
.place-card .address i { color: var(--primary); font-size: 0.8rem; }
.place-card .desc { font-size: 0.875rem; line-height: 1.5; color: var(--text-secondary); margin-bottom: 10px; }

.place-contacts {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 10px; font-size: 0.8rem;
}
.place-contacts a {
  color: var(--primary-dark); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--primary-light); padding: 3px 10px;
  border-radius: var(--radius-pill); transition: all 0.2s;
}
.place-contacts a:hover { background: var(--primary); color: white; }

.place-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border);
}
.place-meta { font-size: 0.75rem; color: var(--text-muted); }

/* Карта */
.map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

/* Кастомные маркеры */
.custom-marker {
  background: var(--primary); border: 3px solid white;
  border-radius: 50% 50% 50% 0; width: 36px; height: 36px;
  transform: rotate(-45deg); display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); transition: all 0.2s;
}
.custom-marker i { transform: rotate(45deg); color: white; font-size: 0.9rem; }
.custom-marker:hover { transform: rotate(-45deg) scale(1.2); }
.custom-marker.marker-courses { background: #3B6EA5; }
.custom-marker.marker-meetups { background: var(--accent); }
.custom-marker.marker-clubs { background: #8B5FA3; }

/* Кластеры */
.marker-cluster-small { background-color: rgb(31 122 77 / 0.55); }
.marker-cluster-medium { background-color: rgb(31 122 77 / 0.65); }
.marker-cluster-large { background-color: rgb(31 122 77 / 0.75); }
.marker-cluster div {
  background-color: var(--primary); color: white;
  font-weight: 700; font-size: 0.9rem;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid white; box-shadow: var(--shadow);
}

/* Попап */
.leaflet-popup-content-wrapper { border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 0; }
.leaflet-popup-content { margin: 0; width: 300px !important; }
.popup-content { padding: 16px; }
.popup-content h3 { font-family: var(--font-display); margin: 0 0 6px 0; font-size: 1.1rem; }
.popup-content .address { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 10px; }
.popup-content .desc { font-size: 0.9rem; line-height: 1.4; color: var(--text-secondary); margin-bottom: 12px; }
.popup-contacts {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 12px; font-size: 0.85rem;
}
.popup-contacts a {
  color: var(--primary-dark); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.popup-contacts a:hover { text-decoration: underline; }

.popup-actions { display: flex; gap: 8px; }
.popup-actions button {
  flex: 1; padding: 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-color);
  cursor: pointer; font-size: 0.85rem; transition: all 0.2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font-family: var(--font-body);
}
.popup-actions button:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }
.popup-actions button.share-btn { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary); }
.popup-actions button.share-btn:hover { background: var(--primary); color: white; }

/* Модалка */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(27, 42, 34, 0.45); backdrop-filter: blur(4px); }
.modal-content {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; position: relative; z-index: 1;
  box-shadow: var(--shadow-lg); margin: 20px;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.close-btn {
  background: none; border: none; font-size: 1.2rem;
  color: var(--text-muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.close-btn:hover { background: var(--bg-color); color: var(--text-main); }

#addPlaceForm, #addItemForm { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.95rem;
  background: var(--surface); color: var(--text-main);
  transition: all 0.2s; font-family: var(--font-body);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group small { font-size: 0.8rem; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr; gap: 16px; }
.form-row.two-col { grid-template-columns: 1fr 1fr; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border-left: 4px solid var(--primary);
  padding: 14px 20px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  animation: slideIn 0.3s ease; min-width: 300px;
  font-family: var(--font-body);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--primary); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Состояния */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); gap: 12px; }
.loading-state i { font-size: 2rem; color: var(--primary); }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); text-align: center; gap: 12px; }
.empty-state i { font-size: 3rem; opacity: 0.3; color: var(--primary); }

/* Мобильная версия */
@media (max-width: 768px) {
  .nav-links { display: none !important; }
  .mobile-only { display: flex !important; }

  .navbar { padding: 10px 16px; }
  .logo h1 { font-size: 1rem; }
  .logo p { display: none; }
  .nav-actions .btn-primary span { display: none; }

  .search-bar { margin: 10px 16px; padding: 10px 16px; }
  .filters-bar { padding: 2px 16px 12px; }

  .app-container { position: relative; }
  .sidebar {
    position: absolute; top: 0; left: 0; height: 100%;
    width: 85%; max-width: 360px; z-index: 50;
    transform: translateX(-100%); box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .map-container { width: 100%; }

  .mobile-fab {
    position: fixed; bottom: 76px; left: 20px; z-index: 40;
    background: var(--surface); border: 1.5px solid var(--border);
    padding: 12px 20px; border-radius: var(--radius-pill); font-weight: 700;
    box-shadow: var(--shadow-lg); display: flex; align-items: center;
    gap: 8px; cursor: pointer; font-size: 0.9rem; color: var(--text-main);
    font-family: var(--font-body);
  }

  .mobile-tabbar {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
    box-shadow: 0 -4px 16px rgb(27 42 34 / 0.08);
  }
  .mobile-tabbar .tab-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--text-muted); text-decoration: none;
    font-size: 0.68rem; padding: 4px 8px; border-radius: var(--radius-sm);
    flex: 1; text-align: center; font-weight: 600;
  }
  .mobile-tabbar .tab-item i { font-size: 1.15rem; }
  .mobile-tabbar .tab-item.active { color: var(--primary); }

  body { padding-bottom: 60px; }

  .modal-content {
    margin: 0; max-height: 100vh;
    border-radius: var(--radius) var(--radius) 0 0;
    position: fixed; bottom: 0;
  }

  .form-row.two-col { grid-template-columns: 1fr; }

  .toast-container { left: 16px; right: 16px; bottom: 80px; }
  .toast { min-width: auto; width: 100%; }
}
