:root {
  --bg: #ffffff;
  --fg: #1c1c1e;
  --muted: #8a8a8e;
  --line: #e6e6ea;
  --accent: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --gray: #94a3b8;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  --nav-h: 56px; /* высота нижнего меню (без safe-area) */
  /* верхний отступ: notch устройства ИЛИ контентная зона Telegram в фуллскрине */
  --top-safe: max(env(safe-area-inset-top), var(--tg-top-inset, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: light; } /* всегда светлые контролы/скроллбары, даже в тёмном Telegram */
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  overflow: hidden;
}

#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; padding-top: var(--top-safe);
  height: calc(52px + var(--top-safe));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; }
.support-btn {
  border: 0; background: #ffe3e3; color: #d6336c; font-weight: 600;
  padding: 7px 12px; border-radius: 20px; font-size: 13px;
}
.support-btn:active { transform: scale(0.96); }

#map {
  position: fixed; left: 0; right: 0;
  top: calc(52px + var(--top-safe));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  z-index: 1;
}

.legend {
  position: fixed; left: 10px; z-index: 800;
  bottom: calc(14px + var(--nav-h) + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.legend span { display: flex; align-items: center; gap: 6px; }
.legend .dot, .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

.fab {
  position: fixed; right: 14px; z-index: 850; width: 48px; height: 48px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--bg);
  font-size: 22px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(0.94); }
.fab-locate { bottom: calc(82px + env(safe-area-inset-bottom)); }
.fab-refresh { bottom: calc(140px + env(safe-area-inset-bottom)); }

/* нижнее меню как в мобильном приложении */
#bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  display: flex; background: var(--bg); border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
#bottomnav .tab {
  flex: 1; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding-top: 4px;
}
#bottomnav .tab .ti { font-size: 22px; line-height: 1; }
#bottomnav .tab.active { color: var(--accent); }
#bottomnav .tab:active { transform: scale(0.94); }

/* полноэкранная страница вкладки (Избранное / Профиль) */
#page {
  position: fixed; left: 0; right: 0; z-index: 900;
  top: calc(52px + var(--top-safe));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--bg); overflow-y: auto;
  padding: 16px 16px 24px;
}

.add-hint {
  position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 900; background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; max-width: 92vw;
}
.add-hint button { border: 0; background: rgba(255,255,255,0.25); color: #fff; border-radius: 8px; padding: 5px 9px; }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 1500; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1600;
  background: var(--bg); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  max-height: 88vh; overflow-y: auto; padding: 6px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp 0.18s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 8px auto 12px; }

h2.station-name { font-size: 19px; margin: 0 0 4px; }
.station-sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 20px;
  font-size: 13px; font-weight: 600; color: #fff;
}
.s-available { background: var(--green); }
.s-limited { background: var(--amber); }
.s-none { background: var(--red); }
.s-unknown { background: var(--gray); }

.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 13px;
  font-size: 15px; font-weight: 600; margin-top: 10px; background: var(--accent); color: #fff;
}
.btn:active { transform: scale(0.99); }
.btn.secondary { background: #eef1f6; color: var(--fg); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px; }

.report {
  border-top: 1px solid var(--line); padding: 12px 0; display: flex; flex-direction: column; gap: 6px;
}
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.report-meta { color: var(--muted); font-size: 12px; }
.report-author { font-weight: 600; font-size: 13px; }
.report-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: #f1f3f7; border-radius: 8px; padding: 3px 8px; font-size: 12px; color: #444; }
.report-comment { font-size: 14px; }
.report-photo { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; margin-top: 4px; }

.votes { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.vote-btn {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 5px 12px; font-size: 14px;
}
.vote-btn.active-up { background: #e8f7ee; border-color: var(--green); color: var(--green); }
.vote-btn.active-down { background: #fdeaea; border-color: var(--red); color: var(--red); }
.vote-score { font-weight: 700; min-width: 28px; text-align: center; }

label.field { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=number], textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px; font-size: 15px;
  margin-top: 5px; font-family: inherit; background: #fafbfc;
}
textarea { resize: vertical; min-height: 64px; }

.status-pick { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 8px; }
.status-opt {
  border: 2px solid var(--line); border-radius: 12px; padding: 12px 6px; text-align: center;
  font-size: 13px; font-weight: 600; background: var(--bg);
}
.status-opt .ico { font-size: 22px; display: block; margin-bottom: 4px; }
.status-opt.sel-available { border-color: var(--green); background: #e8f7ee; }
.status-opt.sel-limited { border-color: var(--amber); background: #fff6e6; }
.status-opt.sel-none { border-color: var(--red); background: #fdeaea; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  border: 1px solid var(--line); border-radius: 20px; padding: 7px 13px; font-size: 14px; background: var(--bg);
}
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.photo-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.photo-prev { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }

.empty { color: var(--muted); text-align: center; padding: 18px 0; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #1c1c1e; color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 2000;
  font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; text-align: center;
}

/* «Чистая» приглушённая подложка — фильтр ТОЛЬКО на базовый слой (своя панель),
   маркеры/кластеры в других панелях не затрагиваются и остаются яркими. */
.basemap-muted {
  -webkit-filter: grayscale(0.6) saturate(0.55) brightness(1.05) contrast(0.95);
          filter: grayscale(0.6) saturate(0.55) brightness(1.05) contrast(0.95);
}

/* убираем дефолтную белую рамку-коробку Leaflet вокруг divIcon (иначе квадраты) */
.leaflet-div-icon { background: transparent; border: 0; }
.benz-dot, .benz-cluster { background: transparent; border: 0; }

/* спиннер индикатора загрузки */
.ld-spin {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  display: inline-block; animation: ld-rot 0.7s linear infinite;
}
@keyframes ld-rot { to { transform: rotate(360deg); } }

.pin-label {
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px;
  font-size: 11px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Светлая тема всегда (тёмный фон Telegram ломал интерфейс) */
