/* ============================================================================
   РКК-Карта — стили карты и панели управления
   Тёмная «стеклянная» панель поверх карты, акцент — циан (#22d3ee).
   ========================================================================== */

:root {
  --bg-panel: rgba(13, 20, 28, 0.86);
  --bg-input: #101a24;
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.16);
  --text: #e6edf3;
  --text-dim: #93a4b3;
  --border: rgba(255, 255, 255, 0.09);
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: #0e141b;
  color: var(--text);
}

/* --- Карта и обёртка ------------------------------------------------------ */

#map-wrapper { position: relative; width: 100vw; height: 100vh; }

#map, #swipe-map { position: absolute; inset: 0; }
#swipe-map { z-index: 2; } /* в режиме свайпа лежит поверх основной карты */

/* --- Свайп-разделитель ---------------------------------------------------- */

#swipe-handle {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 28px;
  margin-left: -14px;
  z-index: 5;
  cursor: ew-resize;
  touch-action: none; /* чтобы Pointer Events работали на тач-устройствах */
  user-select: none;
}

.swipe-line {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.65);
}

.swipe-grip {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #fff;
  color: #0e141b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* --- Панель управления ---------------------------------------------------- */

#panel {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 10;
  width: 302px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

#panel header h1 { margin: 0; font-size: 16px; letter-spacing: 0.2px; }

.subtitle {
  margin: 4px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-dim);
}

/* равномерные отступы между блоками панели */
#panel section { margin: 0 0 16px; }
#panel section:last-child { margin-bottom: 2px; }

/* --- Меню (гамбургер) ------------------------------------------------------ */

.panel-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.menu-btn {
  width: 34px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.menu-btn:hover { border-color: var(--accent); color: var(--accent); }
.main-menu {
  position: absolute;
  z-index: 30;
  min-width: 264px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: var(--accent-soft); }

/* --- Диалог настроек -------------------------------------------------------- */

.set-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 35;
  width: min(460px, calc(100vw - 40px));
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.set-body { padding: 12px 16px 16px; }
.set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13.5px;
  cursor: pointer;
}
.set-row input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.set-note {
  font-size: 11.5px;
  color: var(--text-dim);
  margin: 10px 0 0;
  line-height: 1.45;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

/* Селекторы: единый вид, стрелка не смещается и не подрезается */
select {
  width: 100%;
  padding: 8px 32px 8px 10px; /* справа — место под стрелку */
  border-radius: 10px;
  background: var(--bg-input) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23aab4c0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--text);
  border: 1px solid var(--border);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
select:focus { outline: 1.5px solid var(--accent); outline-offset: -1px; }

/* Чекбоксы слоёв */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13.5px;
  cursor: pointer;
}
.check-row:hover { color: #fff; }

/* Селектор набора РККА */
.rkk-source { margin-top: 0; }
#rkk-source option.find-new {
  color: var(--accent);
  font-style: italic;
  font-weight: 600;
}

/* --- Маркеры пользователя -------------------------------------------------- */

.rkk-marker {
  width: 17px;
  height: 17px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--mk-color, #f43f5e);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  pointer-events: auto; /* маркеры кликабельны поверх оверлейной карты */
}
.rkk-marker:hover { background: var(--mk-color-hover, #fb7185); }

/* Оверлейная карта: слой исторической карты поверх базовой.
   Смещение географическое (offsetMap.camera), контейнер только позиционирует. */
#offset-map {
  position: absolute;
  inset: 0;
  z-index: 1; /* над базовой картой, под панелью */
  pointer-events: none; /* вся навигация — на основной карте */
}
#offset-map.off-hidden { display: none; }
/* рамка-подсказка в режиме смещения */
#offset-map.offset-editing {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* панель режима смещения */
.offset-panel {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  min-width: 300px;
  padding: 10px 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  cursor: move;
  user-select: none;
}
.offset-hint { font-size: 12.5px; color: var(--text); line-height: 1.45; }
.offset-val { font-size: 12px; color: var(--accent); margin-top: 4px; }
.offset-actions { display: flex; gap: 8px; margin-top: 8px; }
.offset-actions .mk-btn { flex: 1; padding: 6px 10px; font-size: 12.5px; }

.marker-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 210px;
  color: var(--text);
}
.marker-form label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}
.marker-form input {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease;
}
.marker-form input:focus { outline: none; border-color: var(--accent); }
.marker-form-actions { display: flex; gap: 8px; margin-top: 6px; }

.mk-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.mk-btn:hover { background: rgba(255, 255, 255, 0.12); }
.mk-btn.primary { background: var(--accent-soft); border-color: rgba(34, 211, 238, 0.5); }
.mk-btn.primary:hover { background: rgba(34, 211, 238, 0.3); }
.mk-btn.danger { border-color: rgba(244, 63, 94, 0.5); color: #fda4af; }
.mk-btn.danger:hover { background: rgba(244, 63, 94, 0.15); }

.marker-info { font-size: 12.5px; min-width: 150px; }
.marker-info b { color: #fecdd3; }
.mk-coords {
  margin: 3px 0 7px;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.mk-date {
  margin-bottom: 7px;
  font-size: 11px;
  color: var(--text-dim);
}

/* --- Диалог каталога карт источника ---------------------------------------- */

.cat-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  width: min(700px, calc(100vw - 40px));
  max-height: min(78vh, 720px);
  display: flex;
  flex-direction: column;
  font-size: 14.5px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.cat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  cursor: move;          /* окно перетаскивается за шапку */
  user-select: none;
  touch-action: none;
}
.cat-head button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
}
.cat-head button:hover { color: var(--text); }
.cat-body {
  overflow: auto;
  padding: 8px 16px 16px;
}
.cat-note {
  flex: 1;
  font-size: 12.5px;
  color: var(--text-dim);
  text-align: right;
}
.cat-search { padding: 12px 16px 0; }
.cat-search input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.cat-search input:focus { outline: 1.5px solid var(--accent); outline-offset: -1px; }
.cat-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; /* три кнопки + счётчик — на узких экранах переносимся */
  gap: 10px;
  padding: 10px 16px 2px;
}
.seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex: none;
}
.seg button {
  padding: 6px 14px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pos-filter {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.pos-filter input { cursor: pointer; }

/* кнопки «Карты» и «Метки» рядом */
#add-section { display: flex; gap: 8px; }
#add-section .btn { flex: 1; }

/* окно «Метки» — как «Выбор карт», но уже */
.mk-dialog { width: min(480px, calc(100vw - 40px)); }
.mk-row .cat-ctrl { gap: 4px; align-items: center; }

/* заголовок группы меток в списке */
.mk-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px 4px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.mk-group-header .mk-color {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.mk-group-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
/* подписи полей в форме редактирования метки */
.mk-edit-label {
  display: block;
  margin: 8px 0 3px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}
/* в режиме редактирования имя-ячейка разворачивается:
   без этого форма обрезается лимитом строк .cat-name */
.mk-row.mk-editing .cat-name {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
.mk-name input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 5px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease;
}
.mk-name input::placeholder { color: var(--text-dim); opacity: 0.7; }
.mk-name input:focus { outline: none; border-color: var(--accent); }
.mk-name .marker-form-actions { display: flex; gap: 8px; margin-top: 6px; }
.mk-name .mk-btn { flex: 1; padding: 7px 10px; font-size: 13px; }
.mk-name .mk-btn.primary {
  background: var(--accent);
  color: #06202a;
  border-color: var(--accent);
  font-weight: 600;
}

/* плавающая панель режима обводки */
.draw-panel {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(560px, calc(100vw - 40px));
  padding: 10px 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  cursor: move;
  user-select: none;
}
.draw-hint { font-size: 13px; color: var(--text); }
.draw-actions { display: flex; gap: 8px; margin-top: 8px; }
.draw-actions .mk-btn { padding: 5px 12px; font-size: 13px; }

.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.cat-row:last-child { border-bottom: none; }
.cat-name {
  flex: 1;
  font-size: 14.5px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cat-ctrl {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: none;
}
.cat-row .mk-btn { flex: none; min-width: 118px; }
.cat-done {
  font-size: 13px;
  color: #34d399;
  white-space: nowrap;
}
.cat-warn {
  font-size: 13px;
  color: #fbbf24;
  white-space: nowrap;
}
.cat-dl { width: 150px; }
.cat-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin-bottom: 3px;
}
.cat-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.cat-pct {
  font-size: 11.5px;
  color: var(--accent);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.mk-del {
  flex: none;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(244, 63, 94, 0.45);
  background: rgba(244, 63, 94, 0.1);
  color: #fda4af;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  min-width: 40px;
}
.mk-del:hover { background: rgba(244, 63, 94, 0.25); }

/* Диалог-подтверждение удаления */
.confirm-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  width: min(420px, calc(100vw - 40px));
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(244, 63, 94, 0.45);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65);
  padding: 16px 18px;
  text-align: center;
}
.confirm-title {
  font-size: 15px;
  font-weight: 700;
  color: #fda4af;
  margin-bottom: 8px;
}
.confirm-text {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}
.confirm-actions { display: flex; gap: 8px; justify-content: center; }
.confirm-actions .mk-btn { flex: none; min-width: 110px; padding: 7px 12px; }
.confirm-actions .mk-btn.danger { background: rgba(244, 63, 94, 0.18); }
.confirm-actions .mk-btn.danger:hover { background: rgba(244, 63, 94, 0.32); }

input[type='checkbox'] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

/* Бейдж источника (ДЕМО / ЖИВОЙ) */
.badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.badge.demo {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.badge.live {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

/* Слайдер прозрачности */
.opacity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.opacity-ico { color: var(--text-dim); font-size: 11px; }

#opacity,
#opacity-m {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  /* «заливка» трека до текущего значения — визуальная обратная связь */
  background: linear-gradient(to right, var(--accent) var(--val, 60%), rgba(255, 255, 255, 0.14) var(--val, 60%));
  outline: none;
  cursor: pointer;
}
#opacity::-webkit-slider-thumb,
#opacity-m::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
  cursor: grab;
}
#opacity::-webkit-slider-thumb:active,
#opacity-m::-webkit-slider-thumb:active { cursor: grabbing; }
#opacity::-moz-range-thumb,
#opacity-m::-moz-range-thumb {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
  cursor: grab;
}
#opacity::-moz-range-progress,
#opacity-m::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

#opacity-value {
  min-width: 40px;
  text-align: right;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* Кнопки */
.actions { display: flex; gap: 8px; }

.btn {
  flex: 1;
  margin: 0;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(34, 211, 238, 0.28); }
.btn.active {
  background: var(--accent);
  border-color: transparent;
  color: #06212a;
  font-weight: 600;
}
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.06); }

/* Подсказка и подвал панели */
.hint {
  margin: 12px 0 6px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
}
.hint code {
  background: rgba(255, 255, 255, 0.07);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 10.5px;
}

.credits {
  margin: 4px 0 6px;
  font-size: 10.5px;
  color: rgba(147, 164, 179, 0.6);
}

/* --- Тост-уведомление ------------------------------------------------------ */

#toast {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(92vw, 560px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(13, 20, 28, 0.92);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}

/* --- Всплывающее окно полосы съёмки --------------------------------------- */

.fp-popup { font-size: 12px; line-height: 1.55; }
.fp-popup b { color: #0e7490; }

.maplibregl-popup-content {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 10px 12px;
}
.maplibregl-popup-tip { border-top-color: var(--bg-input) !important; border-bottom-color: var(--bg-input) !important; }

/* --- Небольшая адаптация стандартных контролов MapLibre под тёмную тему ---- */

.maplibregl-ctrl-attrib {
  background: rgba(13, 20, 28, 0.75) !important;
  color: var(--text-dim);
}
.maplibregl-ctrl-attrib a { color: #bcd0de; }

.maplibregl-ctrl-group {
  background: rgba(13, 20, 28, 0.85) !important;
  border: 1px solid var(--border) !important;
}
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }

.maplibregl-ctrl-scale {
  background: rgba(13, 20, 28, 0.6);
  color: var(--text-dim);
  border-color: var(--text-dim) !important;
}

/* --- Мобильные экраны ------------------------------------------------------ */

@media (max-width: 640px) {
  #panel { width: calc(100vw - 28px); }
}

/* крестовина стрелок смещения */
.offset-pad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(2, 40px);
  gap: 6px;
  justify-content: center;
  margin: 10px 0 2px;
}
.offset-pad .off-arrow {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
}
.offset-pad .off-arrow:active { background: var(--accent-soft); }
.offset-pad .off-arrow[data-off-dir='up'] { grid-column: 2; grid-row: 1; }
.offset-pad .off-arrow[data-off-dir='left'] { grid-column: 1; grid-row: 2; }
.offset-pad .off-arrow[data-off-dir='down'] { grid-column: 2; grid-row: 2; }
.offset-pad .off-arrow[data-off-dir='right'] { grid-column: 3; grid-row: 2; }

/* крестик закрытия попапа метки: заметный, крупный (MapLibre) */
.maplibregl-popup-close-button {
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  margin: 3px 3px 0 0;
  font-size: 20px !important;
  line-height: 26px !important;
  font-weight: 700;
  color: #8fa1b3 !important;
  background: transparent;
  border-radius: 8px;
  transition: background 0.12s ease, color 0.12s ease;
}
.maplibregl-popup-close-button:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.12) !important;
  border-radius: 8px;
}

/* --- Экран входа: чистая страница (карта/меню скрыты до входа) ------------- */
body.auth-pending #map-wrapper { display: none; }
#login-overlay {
  position: fixed; inset: 0; z-index: 5000;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(165deg, #101b28 0%, #1e3345 48%, #37536b 100%);
  overflow: hidden;
}
#login-overlay[hidden] { display: none; }

/* схематичный пейзаж: прижат к низу, масштабируется без кадрирования —
   солнце и горы видны целиком на любом разрешении */
.login-scene {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  height: auto;
  max-height: 94vh;
  pointer-events: none;
  user-select: none;
}
.login-scene .sun-glow { animation: sunGlow 6s ease-in-out infinite; }
@keyframes sunGlow {
  0%, 100% { opacity: 0.75; }
  50%      { opacity: 1; }
}

#login-box {
  position: relative; z-index: 2;
  width: min(340px, calc(100vw - 40px));
  background: rgba(16, 24, 32, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px; padding: 26px 24px 20px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.login-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
#login-box .field-label { display: block; margin: 10px 0 4px; font-size: 12px; color: #9aa7b4; }
#login-box input[type="text"],
#login-box input[type="password"] {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05); color: #e6edf3; font-size: 14px;
}
#login-box input:focus { outline: none; border-color: var(--accent); }
#login-err { margin-top: 10px; font-size: 13px; color: #ff8f9f; }
#login-go {
  width: 100%; margin-top: 14px; padding: 10px;
  background: var(--accent); color: #06202a; font-weight: 600;
  border: none; border-radius: 8px; cursor: pointer; font-size: 14px;
}
#login-go:hover { filter: brightness(1.08); }
#login-go:active { transform: translateY(1px); }

/* ===========================================================================
   UI-POLISH: единый вид форм, диалогов, списков и кнопок
   =========================================================================== */

/* --- Поля ввода: один стиль во всех окнах ---------------------------------- */

/* текстовые поля — на всю ширину окна */
.cat-dialog input[type="text"],
.cat-dialog input[type="search"],
.cat-dialog input[type="password"],
.cat-dialog input[type="number"],
.cat-dialog input[type="email"],
.set-dialog input[type="text"],
.set-dialog input[type="password"],
.set-dialog input[type="number"],
.set-dialog input[type="email"] {
  width: 100%;
  display: block;
  box-sizing: border-box;
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="number"] {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input[type="text"]::placeholder,
input[type="search"]::placeholder,
input[type="password"]::placeholder { color: var(--text-dim); opacity: 0.75; }
input[type="text"]:focus,
input[type="search"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.14);
}
input:hover:not(:focus):not([type="checkbox"]):not([type="range"]):not([type="color"]),
select:hover:not(:focus) { border-color: rgba(255, 255, 255, 0.2); }

/* курсор-перчатка и ховер для всех кликабельных элементов */
button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: default; }

/* фокус с клавиатуры — заметен, но не раздражает */
button:focus-visible, .menu-item:focus-visible { outline: 2px solid rgba(34, 211, 238, 0.55); outline-offset: 1px; }

/* --- Икон-кнопки строк (👁 ✎ ➤ 🙈 🔒 🗝 👑 📦 ✏️) ---------------------------- */

.mk-eye {
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.mk-eye:hover {
  background: var(--accent-soft);
  border-color: rgba(34, 211, 238, 0.35);
  color: var(--accent);
}
.mk-eye:active { transform: scale(0.92); }

/* --- Кнопка ✕ в шапках окон ------------------------------------------------ */

.cat-head button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  transition: background 0.12s ease, color 0.12s ease;
}
.cat-head button:hover {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
}

/* --- Кнопки: отклик на нажатие и переходы ---------------------------------- */

.mk-btn, .btn, .mk-del, .seg button, .menu-item {
  transition: background 0.13s ease, border-color 0.13s ease, color 0.13s ease, filter 0.13s ease;
}
.btn:active, .mk-btn:active, .mk-del:active { transform: translateY(1px); }

/* основная кнопка — заливка акцентом (была полупрозрачной) */
.mk-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06202a;
  font-weight: 600;
}
.mk-btn.primary:hover { background: #3ddcf5; filter: none; }

/* включённый ластик и другие переключаемые кнопки панелей */
.mk-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #06202a;
  font-weight: 600;
}

/* --- Строки списков: ховер и выделение ------------------------------------- */

.cat-row {
  margin: 0 -10px;
  padding: 9px 10px;
  border-radius: 8px;
  transition: background 0.12s ease;
}
.cat-row:hover { background: rgba(255, 255, 255, 0.04); }
.cat-row:last-child { border-bottom-color: transparent; }

/* выбранный пользователь в окне «Пользователи» */
.cat-row.usr-sel {
  background: var(--accent-soft);
  box-shadow: inset 2.5px 0 0 var(--accent);
}
.cat-row.usr-sel:hover { background: rgba(34, 211, 238, 0.2); }

/* чекбокс-строки пакетов — как карточки */
#pkg-maps label,
#pkg-groups label {
  padding: 5px 8px !important;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}
#pkg-maps label:hover,
#pkg-groups label:hover { background: rgba(255, 255, 255, 0.05); }

/* чекбоксы чуть крупнее и с акцентом */
input[type="checkbox"] { width: 16px; height: 16px; }

/* --- Анимации появления окон ----------------------------------------------- */

@keyframes dlgIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes panelIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.cat-dialog, .set-dialog { animation: dlgIn 0.16s ease-out; }
.confirm-box { animation: popIn 0.14s ease-out; }
.offset-panel, .draw-panel { animation: panelIn 0.16s ease-out; }

/* --- Скроллбары в тёмной теме ---------------------------------------------- */

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.28); }
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }

/* --- Поиск по каталогу: иконка лупы ---------------------------------------- */

.cat-search {
  position: relative;
  margin: 12px 16px 0; /* контейнер обнимает поле — лупа не съезжает */
  padding: 0;
}
.cat-search input { padding-left: 34px; }
.cat-search::before {
  content: '🔍';
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  line-height: 1;
  opacity: 0.55;
  pointer-events: none;
  z-index: 1;
}

/* --- Тост-уведомления ------------------------------------------------------ */

#toast {
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 11px 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Пикер цвета группы ----------------------------------------------------- */

.mk-group-header .mk-color { transition: transform 0.12s ease, border-color 0.12s ease; }
.mk-group-header .mk-color:hover { transform: scale(1.12); border-color: #fff; }

/* --- Шапка диалога: лёгкий градиент и тень при прокрутке ------------------- */

.cat-head {
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), transparent);
  flex: none;
}
.cat-body { flex: 1; min-height: 0; }

/* заголовки групп в списках — прилипают при прокрутке */
.mk-group-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(13, 20, 28, 0.96);
  margin: 0 -10px;
  padding: 8px 12px 6px;
}

/* --- Слайдер прозрачности: увеличенная зона комфорта ----------------------- */

#opacity { height: 6px; }
#opacity-m { height: 6px; }
#opacity::-webkit-slider-thumb { transition: transform 0.12s ease; }
#opacity:hover::-webkit-slider-thumb,
#opacity-m:hover::-webkit-slider-thumb { transform: scale(1.15); }

/* --- SVG-иконки меню и кнопок ----------------------------------------------- */

.mi-ico {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* пункты меню: иконка + подпись, ховер со сдвигом */
.menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 16px;
  transition: background 0.13s ease, color 0.13s ease, padding-left 0.13s ease;
}
.menu-item span { flex: 1; text-align: left; }
.menu-item .mi-ico { color: var(--text-dim); transition: color 0.13s ease, transform 0.13s ease; }
.menu-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
  padding-left: 20px;
}
.menu-item:hover .mi-ico { color: var(--accent); transform: scale(1.1); }

/* разделитель и «Выйти» с красным откликом */
.menu-sep { height: 1px; background: var(--border); margin: 5px 10px; }
.menu-item.danger:hover {
  background: rgba(244, 63, 94, 0.12);
  color: #fda4af;
}
.menu-item.danger:hover .mi-ico { color: #fda4af; }

/* кнопки панели: иконка + подпись по центру */
#add-section .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
#add-section .btn .mi-ico { width: 15px; height: 15px; opacity: 0.85; }
#add-section .btn:hover { color: var(--accent); }
#add-section .btn:hover .mi-ico { opacity: 1; transform: translateY(-1px); }

/* --- Экспорт меток в KMZ: выбор точек, название, история выгрузок ---------- */
.exp-form { display: flex; flex-direction: column; gap: 8px; padding: 12px 0 6px; }
.exp-form input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.exp-form input[type="text"]:focus { outline: 1.5px solid var(--accent); outline-offset: -1px; }
.exp-sec-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.exp-sec-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.exp-sec-row .cat-note { flex: 1; }
.exp-group label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.exp-mk { cursor: pointer; }
.exp-mk input[type="checkbox"] { flex: none; width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.exp-mk .cat-name { flex: 1; min-width: 0; }
.exp-mk-date { flex: none; font-size: 11.5px; color: var(--text-dim); }
.exp-foot { display: flex; justify-content: flex-end; padding: 10px 0 4px; }
.exp-do {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #06232b;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.exp-do:hover { filter: brightness(1.12); }
.exp-do:disabled { opacity: 0.6; cursor: default; }
.exp-hist-title {
  margin: 12px 0 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.exp-hist-row { display: flex; align-items: center; gap: 6px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.exp-hist-wrap:last-child .exp-hist-row { border-bottom: none; }
.exp-hist-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-hist-name small { color: var(--text-dim); font-weight: 400; }
.exp-hist-row button {
  flex: none;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  padding: 2px 4px;
}
.exp-hist-row button:hover { color: var(--accent); }
.exp-items { padding: 2px 0 8px; font-size: 12.5px; color: var(--text-dim); }
.exp-items div { padding: 1px 0 1px 14px; }
.exp-items .exp-missed { color: #e05656; }

/* ============================================================
   МОБИЛЬНАЯ ВЕРСИЯ: панель-шторка снизу, полноэкранные окна,
   крупные сенсорные цели, безопасные отступы (вырезы)
   ============================================================ */
@media (max-width: 760px) {

  /* --- панель управления → нижняя шторка --- */
  #panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    /* +safe-area: box-sizing border-box включает нижний отступ в max-height,
     * иначе на телефоне виден только маленький край шапки */
    max-height: calc(70px + env(safe-area-inset-bottom, 0px));
    padding: 0 14px calc(10px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    box-shadow: 0 -14px 36px rgba(0, 0, 0, 0.55);
    transition: max-height 0.26s cubic-bezier(0.22, 0.9, 0.3, 1);
    overflow: hidden;
    z-index: 25;
  }
  body.panel-open #panel {
    max-height: calc(min(74vh, 600px) + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .panel-top {
    position: relative;
    min-height: 46px;
    margin-bottom: 12px;
    padding: 13px 0 8px;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
  }
  .panel-top::before {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 46px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
  }
  .panel-top::after {
    content: '⌃';
    position: absolute;
    right: 56px;
    top: 50%;
    margin-top: -13px;
    font-size: 15px;
    color: var(--text-dim);
    transition: transform 0.2s ease;
  }
  body.panel-open .panel-top::after { transform: rotate(180deg); }
  .panel-title { font-size: 14px; }
  .menu-btn { width: 40px; height: 38px; font-size: 17px; }

  /* --- меню: раскрывается над кнопкой на всю ширину --- */
  .main-menu {
    left: 12px !important;
    right: 12px !important;
    min-width: 0;
    max-height: 62vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .menu-item { padding: 14px 16px; font-size: 15px; }
  .menu-item .mi-ico { width: 18px; height: 18px; }

  /* --- все диалоги → во весь экран --- */
  .cat-dialog,
  .set-dialog {
    top: 0 !important;
    left: 0 !important;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
  }
  .cat-head { padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; font-size: 17px; }
  .cat-head button { width: 40px; height: 40px; font-size: 20px; }

  /* --- центрируемые окна в пределах экрана --- */
  .confirm-box { width: calc(100vw - 24px); }
  .offset-panel { max-width: calc(100vw - 16px); min-width: 0; width: max-content; }
  .draw-panel { max-width: calc(100vw - 16px); }

  /* --- сенсорные цели; 16px в полях — без авто-зума iOS --- */
  #panel select,
  #panel input[type="text"],
  .cat-dialog input[type="text"],
  .cat-dialog input[type="search"],
  .cat-dialog input[type="password"],
  .set-dialog input[type="text"],
  .set-dialog input[type="password"],
  #login-box input {
    font-size: 16px;
  }
  #panel select { min-height: 42px; }
  .cat-row { padding: 11px 0; }
  .cat-name { font-size: 15px; }
  .mk-eye { min-width: 38px; min-height: 34px; }
  #opacity { height: 30px; }
  .pos-filter { padding: 8px 0; font-size: 14px; }

  /* --- кнопка выгрузки KMZ на всю ширину --- */
  .exp-do { width: 100%; padding: 13px 18px; font-size: 15px; }
  .exp-hist-row button { min-width: 36px; min-height: 34px; font-size: 17px; }

  /* --- элементы карты: не прячутся под шторкой --- */
  .maplibregl-ctrl-bottom-left { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
  #toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 24px); }
  .maplibregl-popup { max-width: calc(100vw - 24px) !important; }

  /* --- экран входа --- */
  #login-box { width: calc(100vw - 28px); padding: 22px 18px 18px; }
}

/* невысокие экраны: шторке чуть больше места */
@media (max-width: 760px) and (max-height: 620px) {
  #panel { max-height: 82vh; }
}

/* --- Прозрачность слоя: строка в панели + минималистичное окно -------------- */
.opacity-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.13s ease;
}
.opacity-open:hover { border-color: var(--accent); }
.opacity-open .field-label { margin: 0; }
.opacity-open-val { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-dim); }
.opacity-open-ico { color: var(--accent); font-size: 17px; }

/* ручка переноса окна: полоска сверху, курсор «move» */
.op-grip {
  height: 16px;
  cursor: move;
  position: relative;
  touch-action: none;
}
.op-grip::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 42px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
}
.op-grip:hover::before { background: rgba(255, 255, 255, 0.4); }
.op-dialog.op-dragging, .op-dialog.op-dragging * { cursor: move !important; user-select: none; }

/* окно: только полоска с ползунком */
/* узкая полупрозрачная подложка: плотно обтягивает ползунок.
 * По умолчанию прижата к верхнему краю с отступом 14px — как панель «Карты». */
.op-dialog {
  width: min(420px, calc(100vw - 40px));
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 12, 18, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
}
.op-body { padding: 2px 14px 10px; }
.op-grip { height: 12px; }
.op-body { padding: 14px 18px 12px; }
.op-grip { height: 14px; }
.op-body #opacity { width: 100%; }

/* мобильная полоса прозрачности: прикреплена к верху, видна всегда, полупрозрачная */
.opacity-bar {
  display: none;
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  z-index: 25;
  align-items: center;
  gap: 8px;
  width: min(250px, calc(100vw - 16px));
  padding: 7px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 12, 18, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.opacity-bar .chip-ico { color: var(--accent); font-size: 15px; }
.opacity-bar output {
  min-width: 36px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.opacity-bar #opacity-m { flex: 1; }
@media (max-width: 760px) {
  .opacity-bar { display: flex; }
  #opacity-open { display: none; } /* в панели строка не нужна — полоса уже на карте */
  .op-dialog {
    top: 50% !important;
    left: 50% !important;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: calc(100vw - 32px);
    height: auto;
    max-height: 80vh;
    border: 1px solid var(--border);
    border-radius: 16px;
  }
  .op-body { padding: 30px 18px; }
  .op-body #opacity { height: 34px; }
}

/* полоса на весь экран: крупный ползунок, кнопки карты (+/−, компас) скрыты */
@media (max-width: 760px) {
  .opacity-bar {
    left: 0;
    right: 0;
    width: auto;
    border-radius: 0;
    border-top: none;
    border-left: none;
    border-right: none;
    padding: 12px 14px;
    gap: 12px;
  }
  .opacity-bar #opacity-m { height: 14px; flex: 1; }
  .opacity-bar #opacity-m::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
    border-width: 4px;
  }
  .opacity-bar #opacity-m::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-width: 4px;
  }
  .maplibregl-ctrl-top-right { display: none; } /* +/− и компас — только на десктопе */
}

/* группы в окне экспорта: сворачиваемые */
.exp-group { cursor: pointer; user-select: none; }
.exp-group input[type="checkbox"] { cursor: pointer; }
.exp-gchev { flex: none; width: 14px; text-align: center; font-size: 11px; color: var(--text-dim); }
.exp-gname { flex: none; }
/* кнопка «Выгрузить» — с текстом, не квадратная */
#mkl-kmz { width: auto; min-width: 0; padding: 0 10px; font-size: 14px; white-space: nowrap; }

/* вкладки в окне экспорта: Экспорт | История */
.exp-tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--border); }
.exp-tab {
  padding: 8px 14px 9px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.exp-tab:hover { color: var(--text); }
.exp-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* метки в составе выгрузки — ссылки «показать на карте» */
.exp-item-link { color: var(--accent); text-decoration: none; cursor: pointer; }
.exp-item-link:hover { text-decoration: underline; }

/* название записи в истории — клик разворачивает состав */
.exp-hist-name { cursor: pointer; }
.exp-hist-name:hover b { color: var(--accent); }

/* группы в окне «Метки»: сворачиваемые, с видимостью на карте и переименованием */
.mk-group-header { cursor: pointer; user-select: none; }
.mk-group-header input[type="color"],
.mk-group-header .mk-eye { cursor: pointer; }
.mk-gchev { flex: none; width: 13px; text-align: center; font-size: 10px; color: var(--text-dim); }
.mk-gname { flex: none; }
.mk-goff { opacity: 0.4; }

/* inline-переименование группы в шапке */
.grp-ren-input {
  width: 130px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

/* форма метки: выпадающий список групп + поле новой группы */
.marker-form select {
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.marker-form #mk-group-new { margin-top: -2px; }

/* --- Обмен группами меток: конверт + диалоги -------------------------------- */
.share-btn {
  position: absolute;
  top: 150px;
  right: 14px;
  z-index: 25;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 19px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-btn .share-cnt {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #e05656;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.share-btn.share-blink .share-ico { display: inline-block; animation: shareBlink 0.9s ease-in-out infinite; }
@keyframes shareBlink { 50% { opacity: 0.15; } }
@media (max-width: 760px) {
  .share-btn { top: calc(66px + env(safe-area-inset-top, 0px)); right: 10px; }
}
.share-dialog { width: min(430px, calc(100vw - 40px)); }
.share-body { padding: 16px 18px; }
.share-group-name { margin-bottom: 10px; font-size: 14px; }
.share-group-name b { color: var(--accent); }
.share-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.share-row .cat-ctrl { gap: 6px; }
.share-applied { opacity: 0.55; }

/* мобильный: «Входящие группы» — на весь экран, «Поделиться» — карточка по центру */
@media (max-width: 760px) {
  .share-inb-dialog {
    top: 0 !important;
    left: 0 !important;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
  }
  .cat-head { padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; }
  .share-send-dialog {
    top: 50% !important;
    left: 50% !important;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: calc(100vw - 32px);
    height: auto;
    max-height: 80vh;
    border: 1px solid var(--border);
    border-radius: 16px;
  }
  .share-body { padding: 14px 16px; }
}

/* выделение области на карте (окно экспорта) */
.exp-select-rect {
  position: absolute;
  z-index: 25;
  border: 2px dashed var(--accent);
  background: rgba(34, 211, 238, 0.12);
  pointer-events: none;
}
#exp-select.active { border-color: var(--accent); color: var(--accent); }

/* активный режим выделения области (своя кнопка — без заливки .mk-btn.active) */
#exp-select.exp-sel-on {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-input);
}
#exp-select.exp-sel-on:hover { background: var(--bg-input); }
/* пульс подсветки меток, попавших в область */
@keyframes mkHlPulse {
  0%, 55% { background: rgba(34, 211, 238, 0.28); }
  100% { background: transparent; }
}
.mk-row.mk-hl { animation: mkHlPulse 2.6s ease-out; }

/* редактирование названия метки в попапе на карте */
.marker-info input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.marker-info input:focus { outline: none; border-color: var(--accent); }

/* крестик закрытия карточки метки — справа наверху */
.mk-info-top { display: flex; justify-content: flex-end; margin: -2px -2px 4px 0; }
.mk-info-top .mk-btn { flex: none; min-width: 26px; width: 26px; padding: 3px 0; font-size: 12px; line-height: 1; }

/* комментарии к меткам */
.cmt-dialog { width: min(460px, calc(100vw - 40px)); }
.cmt-body { padding: 12px 16px 14px; }
.cmt-filters { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.cmt-filters input[type="search"],
/* нативный значок календаря в полях даты — светлый на тёмной теме */
input[type="date"] { color-scheme: dark; }
.cmt-filters input[type="date"] {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.cmt-dates { display: flex; gap: 10px; align-items: center; }
.cmt-dates label { display: flex; gap: 5px; align-items: center; font-size: 12px; color: var(--text-dim); }
.cmt-row .cat-name b { display: block; margin-bottom: 2px; white-space: normal; }
.cmt-row .cat-name small { color: var(--text-dim); }
.cmt-pin { vertical-align: -2px; opacity: 0.75; }
.cmt-add { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.cmt-add textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  resize: vertical;
}
.cmt-add textarea:focus { outline: 1.5px solid var(--accent); outline-offset: -1px; }
.cmt-add-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.cmt-add-row .mk-edit-label { margin: 0; }
.cmt-add-row input[type="date"] {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.cmt-add-row .mk-btn { margin-left: auto; }

/* окно «Комментарии» (все комментарии пользователя) */
.cmt-all-dialog { width: min(560px, calc(100vw - 40px)); }
.cmta-go { color: var(--accent); text-decoration: none; cursor: pointer; }
.cmta-go:hover { text-decoration: underline; }
.cmt-filters select {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.cmt-filters .cat-note { white-space: nowrap; }

/* комментарий показывается целиком (без обрезки на 2 строки) */
.cmt-row .cat-name,
.cmt-row .cat-name b {
  white-space: normal;
  overflow: visible;
  -webkit-line-clamp: unset;
  word-break: break-word;
}

/* мобильный: окна комментариев («Комментарии» из меню и у метки) — на весь экран */
@media (max-width: 760px) {
  .cmt-dialog, .cmt-all-dialog {
    top: 0 !important;
    left: 0 !important;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
  }
  .cmt-body { padding: 12px 14px; }
  .cmt-add-row input[type="date"] { max-width: 150px; }
}

/* редактирование комментария (inline) */
.cmt-edit-text {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  resize: vertical;
}
.cmt-edit-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.cmt-edit-row label { font-size: 12px; color: var(--text-dim); }
.cmt-edit-row input[type="date"] {
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.cmt-edit-btns { display: inline-flex; gap: 8px; }
/* кнопки в строке правки — компактные (перебивают min-width:118px у .cat-row .mk-btn) */
.cmt-edit-row .mk-btn { min-width: 0; flex: none; padding: 5px 12px; font-size: 13px; }
/* конверт ✉ прячет, пока открыт попап на точке */
.share-btn.tmp-hide { display: none !important; }

/* теги комментария */
.cmt-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.cmt-tag {
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.cmt-tag.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.cmt-tag-badge {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 7px;
  border-radius: 9px;
  border: 1px solid rgba(34, 211, 238, 0.4);
  color: var(--accent);
  font-size: 11px;
  white-space: nowrap;
}

/* свой тег: поле + кнопка в форме комментария */
.cmt-new-tag-row { display: flex; gap: 6px; align-items: center; margin: 4px 0 6px; }
.cmt-new-tag-row input {
  flex: 1;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.cmt-new-tag-row .mk-btn { flex: none; padding: 4px 10px; }
/* чипы в inline-редактировании комментария */
.cmt-tags-edit { margin: 4px 0; }
