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

html, body {
  height: 100%;
  font-family: "Roboto", -apple-system, "Segoe UI", Arial, sans-serif;
}

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Панель — наложением поверх карты, полупрозрачная (карта видна сквозь неё). */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  height: 100%;
  z-index: 800;
  padding: 20px;
  /* Плотная тёмная панель, чуть светлее карты + край и тень — чтобы визуально
     отделялась от карты, а не сливалась с тёмным фоном. */
  background: rgba(22, 28, 36, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-right: 1px solid #2b3540;
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.5);
  color: #e4e7eb;
  overflow-y: auto;
}

#sidebar h1 {
  font-size: 20px;
  margin-bottom: 6px;
}

.hint {
  font-size: 13px;
  color: #9aa5b1;
  margin-bottom: 18px;
  line-height: 1.4;
}

/* Описание сайта (правится в админке) */
.site-desc {
  font-size: 13px;
  color: #cbd2d9;
  line-height: 1.45;
  margin-bottom: 12px;
}
.site-desc:empty {
  display: none;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9aa5b1;
  margin-bottom: 6px;
}

select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #3e4c59;
  border-radius: 6px;
  background: #323f4b;
  color: #e4e7eb;
  font-size: 14px;
}

/* --- Легенда-фильтр --- */
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 14px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  color: #e4e7eb;
}

.legend-row input {
  cursor: pointer;
  accent-color: #2f80ed;
}

/* Цветной кружок в легенде и списке */
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

button {
  width: 100%;
  padding: 9px;
  margin-bottom: 8px;
  border: none;
  border-radius: 6px;
  background: #2f80ed;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover {
  background: #2668c4;
}

#map {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #0e1116;
}

/* Панель лежит поверх карты — уводим левые контролы Leaflet из-под неё. */
.leaflet-left {
  left: 300px;
}

/* Элементы только для админ-страницы (/admin) */
.admin-only {
  display: none;
}
body.admin .admin-only {
  display: block;
}

/* Курсор в режиме постановки метки */
.leaflet-container.placing-cursor {
  cursor: crosshair;
}

/* --- Таймлайн (фильтр по дате добавления) --- */
#timeline {
  position: fixed;
  bottom: 0;
  left: 300px; /* ширина сайдбара на десктопе */
  right: 0;
  z-index: 900;
  padding: 10px 16px;
  /* Плотная панель с границей — чтобы фильтр периода был заметен, не сливался. */
  background: rgba(22, 28, 36, 0.96);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-top: 1px solid #2b3540;
  box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.45);
  color: #e4e7eb;
}

.tl-top {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
#tl-label {
  font-weight: 600;
}
.tl-count {
  color: #9aa5b1;
  font-size: 12px;
}
#tl-reset {
  width: auto;
  margin: 0 0 0 auto;
  padding: 3px 9px;
  font-size: 12px;
  background: #52606d;
}
#tl-reset:hover {
  background: #3e4c59;
}

/* Двойной ползунок: две range-дорожки друг поверх друга */
.tl-slider {
  position: relative;
  height: 26px;
  margin-top: 4px;
}
.tl-track,
.tl-range {
  position: absolute;
  top: 11px;
  height: 4px;
  border-radius: 2px;
}
.tl-track {
  left: 0;
  right: 0;
  background: #3e4c59;
}
.tl-range {
  background: #2f80ed;
}
.tl-slider input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 26px;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none; /* кликабельны только «бегунки» */
}
.tl-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2f80ed;
  border: 2px solid #fff;
  cursor: pointer;
}
.tl-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #2f80ed;
  border: 2px solid #fff;
  cursor: pointer;
}

.tl-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 11px;
  color: #9aa5b1;
}

/* Поднимаем нижние контролы Leaflet (копирайт) над таймлайном.
   Таймлайн ~86px высотой — берём с запасом. */
.leaflet-bottom {
  bottom: 94px;
}

@media (max-width: 640px) {
  #timeline {
    left: 0; /* на мобильном карта во весь экран */
  }
  /* Панель уезжает в шторку — контролы Leaflet возвращаем к левому краю. */
  .leaflet-left {
    left: 0;
  }
}

/* --- Экран входа админа --- */
#admin-gate {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #0e1116;
  display: flex;
  align-items: center;
  justify-content: center;
}
#admin-gate[hidden] {
  display: none;
}
#admin-gate-box {
  width: 320px;
  max-width: 90vw;
  padding: 26px 24px;
  background: #1f2933;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  text-align: center;
}
#admin-gate-box h2 {
  font-size: 20px;
  margin-bottom: 6px;
}
#gate-pass {
  width: 100%;
  padding: 10px;
  margin: 14px 0 10px;
  border: 1px solid #3e4c59;
  border-radius: 6px;
  background: #323f4b;
  color: #e4e7eb;
  font-size: 15px;
}
#gate-error {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 8px;
  min-height: 16px;
}

/* --- Метки-кружки и кластеры --- */
/* Убираем белую подложку у divIcon по умолчанию. */
.leaflet-div-icon {
  background: transparent;
  border: none;
}
.marker-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
}
.cluster-badge {
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.55);
  box-sizing: border-box;
}

/* Активная кнопка «Добавить метку» (режим включён) */
#btn-add.active {
  background: #c0392b;
}
#btn-add.active:hover {
  background: #a93226;
}

/* --- Модальная форма --- */
#modal-backdrop,
#cat-modal-backdrop,
#desc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#modal-backdrop[hidden],
#cat-modal-backdrop[hidden],
#desc-modal-backdrop[hidden] {
  display: none;
}

#modal,
#cat-modal,
#desc-modal {
  width: 340px;
  max-width: 90vw;
  background: #1f2933;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

/* Крестик закрытия формы метки — в верхнем левом углу. */
#modal {
  position: relative;
}
#modal h2 {
  padding-left: 32px; /* освобождаем место под крестик */
}
.modal-close {
  position: absolute;
  top: 14px;
  left: 12px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: #9aa5b1;
  font-size: 20px;
  line-height: 26px;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
}
.modal-close:hover {
  background: #3e4c59;
  color: #fff;
}

/* Капча — поверх формы добавления метки (z-index выше #modal). */
#captcha-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
#captcha-backdrop[hidden] {
  display: none;
}
#captcha-modal {
  position: relative;
  width: 300px;
  max-width: 90vw;
  background: #1f2933;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  text-align: center;
}
#captcha-modal h2 {
  font-size: 17px;
  margin: 0 0 6px;
  padding: 0 24px; /* место под крестик */
}
.captcha-hint {
  margin: 0 0 8px;
  color: #9aa5b1;
  font-size: 14px;
}
.captcha-question {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
  margin: 6px 0 14px;
}
#captcha-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 20px;
  text-align: center;
  background: #12181f;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-radius: 8px;
}
#captcha-input:focus {
  outline: none;
  border-color: #3b82f6;
}
.captcha-error {
  min-height: 18px;
  margin: 6px 0 2px;
  color: #f87171;
  font-size: 13px;
}

body.theme-light #captcha-modal {
  background: #ffffff;
  color: #1f2933;
  border-color: #cbd2d9;
}
body.theme-light #captcha-input {
  background: #f5f7fa;
  color: #1f2933;
  border-color: #cbd2d9;
}
body.theme-light .captcha-hint {
  color: #616e7c;
}

#modal h2,
#cat-modal h2,
#desc-modal h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.modal-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #cbd2d9;
  margin-bottom: 14px;
}

#modal label,
#cat-modal label,
#desc-modal label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9aa5b1;
  margin: 10px 0 5px;
}

#modal input,
#modal textarea,
#cat-modal input,
#desc-modal input,
#desc-modal textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #3e4c59;
  border-radius: 6px;
  background: #323f4b;
  color: #e4e7eb;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
#cat-modal input[type="color"] {
  height: 38px;
  padding: 2px;
}
#cat-modal .modal-cat input {
  width: auto;
}

/* Список категорий в админке */
.cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 14px;
}
.cat-row .cat-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-row button {
  width: auto;
  margin: 0;
  padding: 3px 7px;
  font-size: 13px;
  background: #52606d;
}
.cat-row button:hover {
  background: #3e4c59;
}

#m-media {
  padding: 6px;
  font-size: 13px;
}

/* Предупреждение о том, чего не решает вычистка метаданных */
.warn-note {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: #f1c40f;
}

.muted {
  color: #9aa5b1;
  text-transform: none;
  letter-spacing: normal;
  font-size: 11px;
}

#m-upload {
  margin-top: 10px;
}
#m-upload progress {
  width: 100%;
  height: 8px;
  accent-color: #2f80ed;
}
#m-upload-text {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #9aa5b1;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions button {
  margin-bottom: 0;
}

.modal-actions .secondary {
  background: #52606d;
}
.modal-actions .secondary:hover {
  background: #3e4c59;
}

/* --- Тёмная тема для элементов Leaflet --- */
/* Leaflet задаёт свой шрифт — подменяем на Roboto (попапы, контролы). */
.leaflet-container {
  font-family: "Roboto", -apple-system, "Segoe UI", Arial, sans-serif;
}

.leaflet-bar a,
.leaflet-bar a:hover {
  background: #1f2933;
  color: #e4e7eb;
  border-bottom-color: #3e4c59;
}

.leaflet-bar a:hover {
  background: #323f4b;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #1f2933;
  color: #e4e7eb;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content a {
  color: #6ab0ff;
}

/* Прокручиваемый попап (когда контент выше maxHeight): скролл только по нужде,
   аккуратный тонкий скроллбар сбоку под тёмную тему, без лишней рамки снизу. */
.leaflet-popup-scrolled {
  overflow-y: auto;
  border-bottom: none !important;
  border-top: none !important;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: #52606d #1f2933;
}
.leaflet-popup-scrolled::-webkit-scrollbar {
  width: 8px;
}
.leaflet-popup-scrolled::-webkit-scrollbar-track {
  background: transparent;
}
.leaflet-popup-scrolled::-webkit-scrollbar-thumb {
  background: #52606d;
  border-radius: 4px;
}
.leaflet-popup-scrolled::-webkit-scrollbar-thumb:hover {
  background: #7b8794;
}

.leaflet-container a.leaflet-popup-close-button {
  color: #9aa5b1;
}

/* Копирайт карты (обязателен по лицензии данных OSM) — делаем минимальным и
   ненавязчивым. Ссылки отключаем: некликабельны и без стиля ссылки. */
.leaflet-control-attribution {
  background: rgba(31, 41, 51, 0.45) !important;
  color: #9aa5b1;
  font-size: 9px;
  line-height: 1.2;
  padding: 0 4px !important;
  opacity: 0.55;
}
.leaflet-control-attribution:hover { opacity: 0.9; }

/* Убираем флажок Украины из копирайта Leaflet */
.leaflet-attribution-flag {
  display: none !important;
}

.leaflet-control-attribution a {
  color: inherit;
  text-decoration: none;
  pointer-events: none; /* ссылки отключены — некликабельны */
  cursor: default;
}

.popup-cat {
  font-size: 12px;
  color: #9aa5b1;
}

.popup-meta {
  margin-top: 4px;
  font-size: 11px;
  color: #9aa5b1;
}

.popup-addr {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.3;
}
.popup-addr a {
  color: #7cb3ff;
  text-decoration: none;
}
.popup-addr a:hover {
  text-decoration: underline;
}
body.theme-light .popup-addr a {
  color: #1b6ec2;
}

.tg-embed {
  display: block;
  width: 100%;
  height: 320px;
  border: 0;
  margin-top: 6px;
  border-radius: 8px;
  background: #16202b;
}

.popup-tg {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
}

.popup-del {
  margin-top: 8px;
  width: auto;
  padding: 5px 10px;
  background: #c0392b;
  font-size: 12px;
}

.popup-del:hover {
  background: #a93226;
}

/* --- Голосование по метке (подтвердить / опровергнуть) --- */
.popup-votes {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
}
.vote-count.confirm {
  color: #27ae60;
}
.vote-count.deny {
  color: #e74c3c;
}

.status-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.status-actions .st-btn {
  width: auto;
  margin-bottom: 0;
  padding: 4px 10px;
  font-size: 12px;
}

.st-btn.confirm {
  background: #27ae60;
}
.st-btn.confirm:hover {
  background: #1f8f4d;
}
.st-btn.deny {
  background: #52606d;
}
.st-btn.deny:hover {
  background: #3e4c59;
}

/* Выбранная пользователем кнопка и заблокированные после голоса */
.st-btn.chosen {
  outline: 2px solid #fff;
  outline-offset: 1px;
}
.st-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.st-btn.deny:disabled:hover {
  background: #52606d;
}
.st-btn.confirm:disabled:hover {
  background: #27ae60;
}

.vote-note {
  margin-top: 6px;
  font-size: 11px;
  color: #9aa5b1;
}

#admin-box {
  padding: 12px;
  background: #16202b;
  border: 1px solid #3e4c59;
  border-radius: 8px;
}

#admin-status {
  font-size: 13px;
  margin-bottom: 8px;
  color: #cbd2d9;
}

#admin-box button {
  margin-bottom: 0;
  background: #52606d;
}

#admin-box button:hover {
  background: #3e4c59;
}

#cat-hint {
  margin: 6px 0 0;
}

/* --- Мобильная версия: карта на весь экран + выезжающая панель --- */
.menu-toggle {
  display: none; /* показывается только на узких экранах */
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1200;
  width: 46px;
  height: 46px;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  background: #1f2933;
  color: #e4e7eb;
  font-size: 22px;
  line-height: 46px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.menu-toggle:hover {
  background: #323f4b;
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1150;
}

@media (max-width: 640px) {
  .menu-toggle {
    display: block;
  }

  /* Карта занимает весь экран */
  #map {
    height: 100%;
    width: 100%;
  }

  /* Панель — выезжающая шторка слева */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 82%;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1180;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.5);
  }

  body.drawer-open #sidebar {
    transform: translateX(0);
  }
  body.drawer-open .drawer-backdrop {
    display: block;
  }
}

/* ==================== СВЕТЛАЯ ТЕМА (класс body.theme-light) ====================
   Наложение поверх тёмной палитры — базовые правила не меняются. Включается
   переключателем «Светлая тема»; выбор сохраняется в localStorage. */
body.theme-light #sidebar {
  background: rgba(247, 249, 251, 0.94);
  color: #1f2933;
  border-right: 1px solid #cbd2d9;
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.12);
}
body.theme-light .hint,
body.theme-light .field label,
body.theme-light .tl-count,
body.theme-light .popup-cat,
body.theme-light .popup-meta {
  color: #52606d;
}
body.theme-light .site-desc {
  color: #3e4c59;
}
body.theme-light .legend-row {
  color: #1f2933;
}
body.theme-light .dot {
  border-color: rgba(0, 0, 0, 0.35);
}

/* Поля ввода / селекты */
body.theme-light select,
body.theme-light #modal input,
body.theme-light #modal textarea,
body.theme-light #cat-modal input,
body.theme-light #desc-modal input,
body.theme-light #desc-modal textarea {
  background: #fff;
  color: #1f2933;
  border-color: #cbd2d9;
}

/* Модальные окна */
body.theme-light #modal,
body.theme-light #cat-modal,
body.theme-light #desc-modal {
  background: #fff;
  color: #1f2933;
  border-color: #cbd2d9;
}
body.theme-light #modal label,
body.theme-light #cat-modal label,
body.theme-light #desc-modal label,
body.theme-light .modal-cat {
  color: #52606d;
}
body.theme-light .modal-close {
  color: #52606d;
}
body.theme-light .modal-close:hover {
  background: #e4e7eb;
  color: #1f2933;
}

/* Всплывающий попап метки */
body.theme-light .leaflet-popup-content-wrapper,
body.theme-light .leaflet-popup-tip {
  background: #fff;
  color: #1f2933;
}
body.theme-light .leaflet-popup-content a {
  color: #1a6fd4;
}
body.theme-light .leaflet-container a.leaflet-popup-close-button {
  color: #52606d;
}
body.theme-light .leaflet-popup-scrolled {
  scrollbar-color: #b0b8c0 #fff;
}
body.theme-light .leaflet-popup-scrolled::-webkit-scrollbar-thumb {
  background: #b0b8c0;
}

/* Таймлайн */
body.theme-light #timeline {
  background: linear-gradient(to top, rgba(247, 249, 251, 0.95) 0%, rgba(247, 249, 251, 0) 100%);
  color: #1f2933;
}
body.theme-light .tl-track {
  background: #cbd2d9;
}

/* Метки и кластеры: тёмная обводка вместо белой — чтобы читались на светлой карте */
body.theme-light .marker-dot,
body.theme-light .cluster-badge {
  border-color: #1f2933;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

/* --- Поле адреса / выбор точки в окне добавления метки --- */
#m-loc-field {
  margin-bottom: 6px;
}
.addr-row {
  display: flex;
  gap: 6px;
}
.addr-row input {
  flex: 1;
}
.addr-btn {
  width: auto;
  white-space: nowrap;
  margin-bottom: 8px;
}
.loc-status {
  font-size: 12px;
  color: #27ae60;
  margin-top: 4px;
  min-height: 15px;
  line-height: 1.3;
  word-break: break-word;
}
.loc-status.err {
  color: #e74c3c;
}

/* Баннер-подсказка в режиме «Указать на карте» */
#pick-hint {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: #2f80ed;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}
#pick-hint[hidden] {
  display: none;
}

/* --- Окно редактирования метки (админ) --- */
#edit-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#edit-modal-backdrop[hidden] {
  display: none;
}
#edit-modal {
  position: relative;
  width: 340px;
  max-width: 90vw;
  background: #1f2933;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#edit-modal h2 {
  font-size: 18px;
  margin-bottom: 12px;
  padding-left: 32px;
}
#edit-modal label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9aa5b1;
  margin: 10px 0 5px;
}
#edit-modal select,
#edit-modal input,
#edit-modal textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #3e4c59;
  border-radius: 6px;
  background: #323f4b;
  color: #e4e7eb;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

/* Кнопки админа в попапе (изменить/удалить) */
.popup-admin {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.popup-admin button {
  width: auto;
  margin: 0;
  padding: 5px 10px;
  font-size: 12px;
}
.popup-edit {
  background: #3e4c59;
}
.popup-edit:hover {
  background: #52606d;
}

/* Светлая тема для окна редактирования */
body.theme-light #edit-modal {
  background: #fff;
  color: #1f2933;
  border-color: #cbd2d9;
}
body.theme-light #edit-modal label {
  color: #52606d;
}
body.theme-light #edit-modal select,
body.theme-light #edit-modal input,
body.theme-light #edit-modal textarea {
  background: #fff;
  color: #1f2933;
  border-color: #cbd2d9;
}

/* --- Окно «Скрытые метки» (админ) --- */
#hidden-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#hidden-modal-backdrop[hidden] {
  display: none;
}
#hidden-modal {
  position: relative;
  width: 420px;
  max-width: 92vw;
  max-height: 80vh;
  overflow-y: auto;
  background: #1f2933;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#hidden-modal h2 {
  font-size: 18px;
  margin-bottom: 6px;
  padding-left: 32px;
}
#hidden-list {
  margin-top: 10px;
}
.hidden-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #3e4c59;
}
.hidden-info {
  flex: 1;
  min-width: 0;
}
.hidden-info b {
  display: block;
  word-break: break-word;
  font-weight: 500;
}
.hidden-meta {
  font-size: 12px;
  color: #9aa5b1;
  margin-top: 2px;
}
.hidden-restore {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Светлая тема */
body.theme-light #hidden-modal {
  background: #fff;
  color: #1f2933;
  border-color: #cbd2d9;
}
body.theme-light .hidden-row {
  border-top-color: #e4e7eb;
}
body.theme-light .hidden-meta {
  color: #52606d;
}

/* Кнопка полного удаления в списке скрытых меток */
.hidden-row {
  flex-wrap: wrap;
}
.hidden-purge {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  background: #c0392b;
}
.hidden-purge:hover {
  background: #a93226;
}

/* --- Тост-уведомление (например «Публикуем в Telegram») --- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 2500;
  max-width: 92vw;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #1f2933;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  font-size: 14px;
}
#toast[hidden] {
  display: none;
}
#toast-text {
  flex: 1;
}
#toast-close {
  width: auto;
  margin: 0;
  padding: 2px 8px;
  background: transparent;
  color: #9aa5b1;
  font-size: 18px;
  line-height: 1;
}
#toast-close:hover {
  background: #3e4c59;
  color: #fff;
}
body.theme-light #toast {
  background: #fff;
  color: #1f2933;
  border-color: #cbd2d9;
}
body.theme-light #toast-close:hover {
  background: #e4e7eb;
  color: #1f2933;
}

/* --- Раздел «Помощь» (сворачивающийся список ресурсов) --- */
#help-section > summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 10px;
  border-radius: 6px;
  background: #323f4b;
  color: #e4e7eb;
  font-size: 14px;
  font-weight: 500;
  user-select: none;
}
#help-section > summary::-webkit-details-marker { display: none; }
#help-section > summary::before { content: "▸ "; color: #9aa5b1; }
#help-section[open] > summary::before { content: "▾ "; }
#help-section > summary:hover { background: #3e4c59; }
.help-links { padding: 6px 2px 2px; }
.help-item {
  padding: 10px 0;
  border-top: 1px solid #3e4c59;
}
.help-item:first-child { border-top: none; }
.help-title { font-size: 14px; font-weight: 600; color: #e4e7eb; }
.help-desc {
  font-size: 12px;
  color: #9aa5b1;
  line-height: 1.4;
  margin: 3px 0 6px;
}
.help-urls { display: flex; flex-wrap: wrap; gap: 6px; }
.help-urls a {
  font-size: 12px;
  color: #6ab0ff;
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid #3e4c59;
  border-radius: 5px;
  white-space: nowrap;
}
.help-urls a:hover { background: #3e4c59; }

body.theme-light #help-section > summary {
  background: #eef1f5;
  color: #1f2933;
}
body.theme-light #help-section > summary:hover { background: #e4e7eb; }
body.theme-light .help-item { border-top-color: #e4e7eb; }
body.theme-light .help-title { color: #1f2933; }
body.theme-light .help-desc { color: #52606d; }
body.theme-light .help-urls a {
  color: #1a6fd4;
  border-color: #cbd2d9;
}
body.theme-light .help-urls a:hover { background: #e4e7eb; }

/* --- Окно статистики (админ) --- */
#stats-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#stats-modal-backdrop[hidden] { display: none; }
#stats-modal {
  position: relative;
  width: 460px;
  max-width: 94vw;
  max-height: 84vh;
  overflow-y: auto;
  background: #1f2933;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#stats-modal h2 { font-size: 18px; margin-bottom: 6px; padding-left: 32px; }
.stats-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.stat-card {
  background: #323f4b;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.stat-val { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12px; color: #9aa5b1; margin-top: 2px; }
.stats-h { font-size: 14px; margin: 16px 0 6px; }
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.stats-table th, .stats-table td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid #3e4c59;
}
.stats-table th { color: #9aa5b1; font-weight: 500; }
.stats-table td:not(:first-child), .stats-table th:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

body.theme-light #stats-modal { background: #fff; color: #1f2933; border-color: #cbd2d9; }
body.theme-light .stat-card { background: #eef1f5; }
body.theme-light .stat-label { color: #52606d; }
body.theme-light .stats-table th { color: #52606d; }
body.theme-light .stats-table th, body.theme-light .stats-table td { border-bottom-color: #e4e7eb; }

/* --- Таймлайн-скраббер (как DeepState) --- */
.tl-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.tl-step, .tl-now {
  width: auto;
  margin: 0;
  padding: 4px 10px;
  font-size: 13px;
  background: #323f4b;
}
.tl-step { padding: 3px 11px; font-size: 17px; line-height: 1; }
.tl-step:hover, .tl-now:hover { background: #3e4c59; }
.tl-date {
  font-size: 15px;
  font-weight: 600;
  min-width: 128px;
}
.tl-date { text-align: center; }

.tl-scrub {
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.tl-scrub::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: #3e4c59;
}
.tl-scrub::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #3e4c59;
}
.tl-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: #2f80ed;
  border: 2px solid #fff;
  cursor: pointer;
}
.tl-scrub::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2f80ed;
  border: 2px solid #fff;
  cursor: pointer;
}

body.theme-light .tl-step, body.theme-light .tl-now { background: #eef1f5; color: #1f2933; }
body.theme-light .tl-step:hover, body.theme-light .tl-now:hover { background: #e4e7eb; }
body.theme-light .tl-scrub::-webkit-slider-runnable-track { background: #cbd2d9; }
body.theme-light .tl-scrub::-moz-range-track { background: #cbd2d9; }

/* «Показать за период» в таймлайне */
.tl-window {
  width: auto;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 6px;
}

/* --- Комментарии/статусы под меткой (в попапе) --- */
.cm-block {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #3e4c59;
}
.cm-status {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.cm-st {
  width: auto;
  margin: 0;
  padding: 4px 8px;
  font-size: 12px;
  background: #323f4b;
  border-radius: 14px;
}
.cm-st:hover { background: #3e4c59; }
.cm-list {
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.cm-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(62, 76, 89, 0.5);
  font-size: 13px;
}
.cm-body { flex: 1; word-break: break-word; }
.cm-badge { font-weight: 600; }
.cm-time {
  color: #9aa5b1;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}
.cm-hide {
  width: auto;
  margin: 0;
  padding: 0 6px;
  font-size: 13px;
  background: transparent;
  color: #9aa5b1;
  flex-shrink: 0;
}
.cm-hide:hover { background: #c0392b; color: #fff; }
.cm-empty { color: #9aa5b1; font-size: 12px; padding: 4px 0; }
.cm-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #3e4c59;
  border-radius: 6px;
  background: #323f4b;
  color: #e4e7eb;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.cm-warn { font-size: 11px; color: #e0a030; margin: 4px 0 6px; }
.cm-send {
  width: auto;
  margin: 0;
  padding: 5px 14px;
  font-size: 13px;
}

body.theme-light .cm-block { border-top-color: #cbd2d9; }
body.theme-light .cm-st { background: #eef1f5; color: #1f2933; }
body.theme-light .cm-st:hover { background: #e4e7eb; }
body.theme-light .cm-item { border-bottom-color: #e4e7eb; }
body.theme-light .cm-time, body.theme-light .cm-empty, body.theme-light .cm-hide { color: #52606d; }
body.theme-light .cm-input { background: #fff; color: #1f2933; border-color: #cbd2d9; }

/* --- Таймлайн: диапазон дат «от — до» --- */
.tl-range-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  font-size: 14px;
}
.tl-lbl { font-weight: 600; font-size: 15px; }
.tl-field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1f2933;
  border: 1px solid #3e4c59;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.tl-field input[type="date"] { cursor: pointer; }
.tl-field > span { color: #9aa5b1; font-size: 13px; }
.tl-field input[type="date"] {
  border: none;
  background: transparent;
  color: #e4e7eb;
  font-size: 15px;
  padding: 0;
  width: auto;
  color-scheme: dark;
  font-family: inherit;
}
.tl-all {
  width: auto;
  margin: 0;
  padding: 7px 14px;
  font-size: 14px;
  background: #323f4b;
}
.tl-all:hover { background: #3e4c59; }
.tl-range-row .tl-count { font-size: 13px; }

/* Мобильный: поля крупнее и растягиваются, кнопка и счётчик — на всю ширину */
@media (max-width: 640px) {
  #timeline { padding: 10px 12px; }
  .tl-range-row { gap: 8px; }
  .tl-field { flex: 1 1 44%; }
  .tl-field input[type="date"] { width: 100%; flex: 1; }
  .tl-all { flex: 1 1 100%; order: 5; }
  .tl-range-row .tl-count { flex: 1 1 100%; order: 6; margin-left: 0; text-align: center; }
}

/* Светлая тема */
body.theme-light #timeline {
  background: rgba(247, 249, 251, 0.96);
  border-top-color: #cbd2d9;
  box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.1);
}
body.theme-light .tl-field {
  background: #fff;
  border-color: #cbd2d9;
}
body.theme-light .tl-field input[type="date"] { color: #1f2933; color-scheme: light; }
body.theme-light .tl-field > span { color: #52606d; }
body.theme-light .tl-all { background: #eef1f5; color: #1f2933; }
body.theme-light .tl-all:hover { background: #e4e7eb; }

/* --- «Сомнительная информация» (карантин) --- */
.dubious-banner {
  margin: 6px 0;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(224, 160, 48, 0.18);
  border: 1px solid rgba(224, 160, 48, 0.55);
  color: #e0a030;
  font-size: 12px;
  line-height: 1.35;
}
.popup-dub { background: #b7791f; }
.popup-dub:hover { background: #9c6717; }
.popup-undub { background: #2e7d46; }
.popup-undub:hover { background: #276b3c; }

/* Неактивная ссылка (напр. временно отключённый канал) */
.link-disabled {
  color: #8a8f98;
  text-decoration: line-through;
  cursor: not-allowed;
  opacity: 0.7;
}

/* --- Модерация и хронология (админ) --- */
.pending-row, .chrono-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid #3e4c59;
}
.pending-info, .chrono-info { flex: 1; min-width: 0; }
.pending-info b, .chrono-info b { display: block; word-break: break-word; font-weight: 500; }
.pending-addr { font-size: 12px; color: #9aa5b1; margin-top: 3px; }
.pending-text {
  font-size: 13px;
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cdd5df;
}
.pending-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.pending-actions button, .chrono-goto {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  white-space: nowrap;
}
.pending-approve { background: #2e7d46; }
.pending-approve:hover { background: #276b3c; }
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 9px;
  background: #d9534f;
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  font-weight: 600;
}
body.theme-light .pending-row, body.theme-light .chrono-row { border-top-color: #d7dde3; }
body.theme-light .pending-text { color: #333; }

/* --- Модалки «На модерации» и «Все метки»: оверлей + скролл --- */
#pending-modal-backdrop, #chrono-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#pending-modal-backdrop[hidden], #chrono-modal-backdrop[hidden] { display: none; }
#pending-modal, #chrono-modal {
  position: relative;
  width: 460px;
  max-width: 92vw;
  max-height: 80vh;
  overflow-y: auto;
  background: #1f2933;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#pending-modal h2, #chrono-modal h2 {
  font-size: 18px;
  margin-bottom: 6px;
  padding-left: 32px;
}
#pending-list, #chrono-list { margin-top: 10px; }
.chrono-actions { display: flex; gap: 6px; flex-shrink: 0; }
.chrono-del { width: auto; margin: 0; padding: 6px 12px; background: #b03a3a; }
.chrono-del:hover { background: #963030; }
body.theme-light #pending-modal, body.theme-light #chrono-modal {
  background: #fff; color: #1f2933; border-color: #cbd2d9;
}

/* --- Объявление в нижнем левом углу --- */
#announce {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 530px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #1f2933;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-left: 6px solid #d9534f;
  border-radius: 14px;
  padding: 24px 52px 24px 26px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.6);
  z-index: 1200;
  font-size: 19px;
  line-height: 1.5;
}
#announce[hidden] { display: none; }
.announce-title { font-weight: 700; font-size: 23px; margin-bottom: 12px; }
.announce-body p { margin: 0 0 8px 0; }
.announce-body p:last-child { margin-bottom: 0; }
.announce-body a { color: #4aa3df; }
.announce-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: auto;
  margin: 0;
  padding: 4px 10px;
  background: transparent;
  color: #9aa5b1;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.announce-close:hover { color: #e4e7eb; }
body.theme-light #announce { background: #fff; color: #1f2933; border-color: #cbd2d9; border-left-color: #d9534f; }
@media (max-width: 560px) {
  #announce {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    text-align: center;
    padding: 22px 24px 22px 24px;
    border-left: 6px solid #d9534f;
    font-size: 18px;
  }
  .announce-title { font-size: 22px; }
  .announce-body a { word-break: break-word; }
}
