* {
    box-sizing: border-box;
}
html {
    margin: 0;
    padding: 0;
    /* M1: position:fixed предотвращает скролл на iOS Safari */
    position: fixed;
    inset: 0;
    overflow: hidden;
}
body {
    margin: 0;
    padding: 0;
    /* M2: safe area top — контент не за камерой/Dynamic Island */
    padding-top: env(safe-area-inset-top, 0px);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: #1A3A32;
    width: 100%;
    height: 100%;
    /* C15: body как flex-контейнер для header + .app */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
}

/* ===== Header (Фаза 1) ===== */
.app-header{
  height:48px;
  flex-shrink:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 75px 0 44px;
  /* M2: safe area для iPhone в landscape (viewport-fit=cover) */
  padding:0 calc(75px + env(safe-area-inset-right, 0px)) 0 calc(44px + env(safe-area-inset-left, 0px));
  background:#142E28;
  border-bottom:none;
  z-index:150;
}
.header-left{ display:flex; align-items:center; gap:8px; }
.header-logo{
  font-size:17px;
  font-weight:700;
  color:#E8A87C;
  letter-spacing:-0.01em;
}
.header-right{ display:flex; align-items:center; gap:10px; }
#header-guest-actions{ display:flex; gap:6px; }
#header-guest-actions .btn{
  border-color:rgba(255,255,255,0.25);
  background:transparent;
  color:#FAF6F0;
}
#header-guest-actions .btn:hover{
  background:rgba(255,255,255,0.1);
}
#header-guest-actions .btn-primary{
  background:#E8A87C;
  border-color:#E8A87C;
  color:#142E28;
}
#header-guest-actions .btn-primary:hover{
  background:#D4956A;
}
#header-user-section{ display:flex; align-items:center; gap:10px; }
.header-user-menu{ position:relative; }
.header-user-btn{
  display:flex;
  align-items:center;
  gap:6px;
  padding:5px 12px;
  border-radius:9999px;
  border:1px solid rgba(255,255,255,0.2);
  background:rgba(255,255,255,0.08);
  cursor:pointer;
  font-size:13px;
  color:#FAF6F0;
  line-height:1;
}
.header-user-btn:hover{ background:rgba(255,255,255,0.15); }
.header-chevron{ font-size:10px; color:rgba(255,255,255,0.5); }
.header-role-badge{
  font-size:10px;
  padding:1px 6px;
  border-radius:9999px;
  background:rgba(232,168,124,0.2);
  color:#E8A87C;
  font-weight:600;
  white-space:nowrap;
}
.header-dropdown{
  display:none;
  position:absolute;
  right:0;
  top:calc(100% + 4px);
  min-width:160px;
  background:#FFFDF8;
  border:1px solid #D6CFC5;
  border-radius:10px;
  box-shadow:0 8px 24px rgba(20,46,40,0.15);
  z-index:200;
  padding:4px 0;
}
.header-dropdown.open{ display:block; }
.header-dropdown-item{
  display:block;
  width:100%;
  padding:8px 14px;
  border:none;
  background:transparent;
  text-align:left;
  cursor:pointer;
  font-size:13px;
  color:#2D5A4A;
}
.header-dropdown-item:hover{ background:#F0EBE3; }
.header-dropdown-item--danger{ color:#C44B3F; }
.header-dropdown-item--danger:hover{ background:#FDF0EE; }

/* ===== Auth modal (Фаза 2) ===== */
.auth-modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(20,46,40,0.5);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
  padding:24px 12px;
}
.auth-modal{
  position:relative;
  width:min(400px, 100%);
  background:#FFFDF8;
  border-radius:16px;
  padding:24px;
  box-shadow:0 20px 60px rgba(20,46,40,0.3);
  max-height:calc(100vh - 48px);
  max-height:calc(100dvh - 48px);
  overflow-y:auto;
}
.auth-modal-close{
  position:absolute;
  top:12px;
  right:12px;
  width:32px;
  height:32px;
  border-radius:50%;
  border:none;
  background:#F0EBE3;
  font-size:18px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#6B8F7F;
  line-height:1;
}
.auth-modal-close:hover{ background:#E0D8CE; }
.auth-link{ color:#2ECC71; font-size:13px; text-decoration:none; }
.auth-link:hover{ text-decoration:underline; }
.auth-modal-heading{
  font-size:18px;
  font-weight:700;
  margin-bottom:12px;
  color:#142E28;
}

/* ===== Settings overlay (Фаза 4) ===== */
.settings-overlay{
  position:fixed;
  inset:0;
  background:#FAF6F0;
  z-index:9990;
  display:flex;
  flex-direction:column;
  /* M2: safe area — контент не за нотчем/камерой */
  padding-top:env(safe-area-inset-top, 0px);
  padding-left:env(safe-area-inset-left, 0px);
  padding-right:env(safe-area-inset-right, 0px);
}
.settings-page{
  max-width:900px;
  width:100%;
  margin:0 auto;
  display:flex;
  flex-direction:column;
  flex:1;
  min-height:0;
}
.settings-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 16px;
  border-bottom:1px solid #D6CFC5;
  flex-shrink:0;
}
.settings-close-btn{
  width:32px;
  height:32px;
  border-radius:50%;
  border:none;
  background:#E8E0D4;
  color:#142E28;
  font-size:16px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
}
.settings-close-btn:hover{ background:#D6CFC5; }
.settings-page-title{
  font-weight:700;
  font-size:16px;
  color:#142E28;
}
.settings-page-body{
  flex:1;
  overflow:hidden;
  padding:0;
  display:flex;
}
/* Двухколоночный layout настроек (телефонная книжка) */
.settings-layout{
  display:flex;
  flex:1;
  min-height:0;
}
.settings-nav{
  width:200px;
  flex-shrink:0;
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:12px 0;
  border-right:1px solid #D6CFC5;
  background:#F5F0E8;
}
.settings-nav-item{
  display:block;
  width:100%;
  padding:9px 16px;
  border:none;
  background:transparent;
  text-align:left;
  font-size:13px;
  color:#6B8F7F;
  cursor:pointer;
  border-right:3px solid transparent;
  transition:background 0.12s, color 0.12s;
}
.settings-nav-item:hover{
  background:#EDE8E0;
  color:#2D5A4A;
}
.settings-nav-item.active{
  background:#FFFDF8;
  color:#1B6B52;
  font-weight:600;
  border-right-color:#1B6B52;
}
.settings-nav-item--danger{
  color:#C44B3F;
}
.settings-nav-item--danger:hover{
  background:#FDF0EE;
  color:#A33D33;
}
.settings-nav-item--danger.active{
  background:#FFFDF8;
  color:#C44B3F;
  border-right-color:#C44B3F;
}
.settings-content{
  flex:1;
  min-width:0;
  padding:28px 36px;
  overflow-y:auto;
  background:#FFFDF8;
}
.settings-panel{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.settings-panel .hint{ line-height:1.5; }
.settings-panel .btn{ align-self:flex-start; }
.settings-field{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.settings-field .btn{ align-self:flex-start; }
.settings-panel-title{
  font-size:15px;
  font-weight:700;
  color:#142E28;
  margin:0 0 10px 0;
}

/* Mobile: навигация сверху */
@media (max-width: 600px) {
  .settings-layout{
    flex-direction:column;
  }
  .settings-nav{
    width:100%;
    flex-direction:row;
    border-right:none;
    border-bottom:1px solid #D6CFC5;
    overflow-x:auto;
    padding:0;
    gap:0;
  }
  .settings-nav-item{
    padding:8px 12px;
    white-space:nowrap;
    border-right:none;
    border-bottom:2px solid transparent;
  }
  .settings-nav-item.active{
    border-right-color:transparent;
    border-bottom-color:#1B6B52;
  }
  .settings-nav-item--danger.active{
    border-right-color:transparent;
    border-bottom-color:#C44B3F;
  }
  .settings-content{
    padding:12px 16px;
  }
}

/* ===== Sidebar tabs (Фаза 3) ===== */
.sidebar-tabs{
  display:flex;
  border-bottom:1px solid #D6CFC5;
  flex-shrink:0;
}
.sidebar-tab{
  flex:1 1 auto;
  min-width:0;
  padding:10px 6px;
  border:none;
  background:transparent;
  font-size:13px;
  font-weight:600;
  color:#6B8F7F;
  cursor:pointer;
  border-bottom:2px solid transparent;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:2px;
  overflow:hidden;
  transition:color 0.15s, border-color 0.15s;
}
.sidebar-tab-label{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.sidebar-tab:hover{ color:#2D5A4A; }
.sidebar-tab.active{
  color:#1B6B52;
  border-bottom-color:#1B6B52;
}
.tab-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:16px;
  height:16px;
  padding:0 4px;
  border-radius:999px;
  background:#D97B5C;
  color:#fff;
  font-size:10px;
  line-height:1;
  margin-left:2px;
  vertical-align:middle;
  flex-shrink:0;
}
.sidebar-tab-content{
  flex:1;
  overflow-y:auto;
  min-height:0;
  /* C16: padding на content, а не на sidebar */
  padding:16px 14px;
  overscroll-behavior:contain; /* W12 */
}

/* ===== Guest mode (Фаза 2) ===== */
/* Применяется через класс на html (FOUC) и на .app (JS) */
.guest-mode .app { grid-template-columns: 1fr; }
.guest-mode .sidebar { display: none; }
/* При наличии класса на .app напрямую */
.app.guest-mode { grid-template-columns: 1fr; }
.app.guest-mode .sidebar { display: none; }

/* ===== Main layout ===== */
.app {
    display: grid;
    grid-template-columns: auto 1fr;
    /* C15: flex:1 вместо height:100vh — чтобы header + app = 100% */
    flex: 1;
    min-height: 0;
    background: #EDE8E0;
}

.sidebar {
    background: #FAF6F0;
    border-right: 1px solid #D6CFC5;
    /* C16: padding убран — теперь в .sidebar-tab-content */
    padding: 0;
    display: flex;
    flex-direction: column;
    /* W5: скролл в tab-content; visible нужен для handle, выступающего за край */
    overflow: visible;
    /* Десктоп: фиксированная ширина + анимация сворачивания */
    width: 280px;
    position: relative;
    transition: width 0.15s ease;
}

/* M6: кнопка сворачивания sidebar — десктоп: вертикальная стрелка на правом краю */
.sidebar-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateX(100%) translateY(-50%);
    width: 18px;
    height: 44px;
    background: #FAF6F0;
    border: 1px solid #D6CFC5;
    border-left: none;
    border-radius: 0 10px 10px 0;
    cursor: pointer;
    z-index: 3;
    padding: 0;
    box-shadow: 2px 0 4px rgba(20,46,40,0.08);
}
.sidebar-handle svg {
    stroke: #6B8F7F;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    /* Стрелка влево = «свернуть» */
    transform: rotate(-90deg);
    transition: transform 0.2s;
}
/* Sidebar свёрнут — ширина 0, контент скрыт */
.sidebar.collapsed {
    width: 0;
    border-right: none;
}
.sidebar.collapsed #authed-only {
    display: none;
}
.sidebar.collapsed .sidebar-handle svg {
    /* Стрелка вправо = «развернуть» */
    transform: rotate(90deg);
}

/* #authed-only внутри sidebar тоже flex-колонка */
#authed-only{
  display:flex;
  flex-direction:column;
  flex:1;
  min-height:0;
  /* Клиппинг контента при анимации ширины sidebar */
  overflow:hidden;
}

.sidebar-section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6B8F7F;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.sidebar h1 {
    font-size: 18px;
    margin: 0 0 4px 0;
    color: #142E28;
}

.sidebar .subtitle {
    font-size: 13px;
    color: #6B8F7F;
}

.card {
    border-radius: 10px;
    border: 1px solid #D6CFC5;
    padding: 10px 10px;
    background: #FFF8F0;
}

.field-label {
    font-size: 13px;
    margin-bottom: 4px;
    color: #2D5A4A;
}

.input {
    width: 100%;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #C5B9A8;
    font-size: 13px;
    outline: none;
    background: #FFFDF8;
}

.input:focus {
    border-color: #1B6B52;
    box-shadow: 0 0 0 1px rgba(27,107,82,0.2);
}

/* ===== Обёртка пароля с глазиком ===== */
.password-wrapper { position: relative; }
.password-wrapper .input { padding-right: 36px; }
.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #9ca3af;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.password-toggle:hover { color: #2D5A4A; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 9999px;
    border: 1px solid #C5B9A8;
    background: #F0EBE3;
    font-size: 13px;
    cursor: pointer;
    color: #2D5A4A;
    transition: background 0.1s, box-shadow 0.1s, transform 0.05s;
}
.btn-primary {
    background: #1B6B52;
    border-color: #1B6B52;
    color: white;
}

.btn-secondary {
    background: #E0D8CE;
    border-color: #C5B9A8;
    color: #2D5A4A;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: #6B8F7F;
}

.btn-ghost:hover {
    background: #F0EBE3;
}

.btn-icon {
    padding: 4px 8px;
    border-radius: 9999px;
    line-height: 1;
    font-size: 16px;
}
.btn:hover {
    background: #E0D8CE;
}
.btn-primary:hover {
    background: #145A44;
}
.btn-danger {
    background: #C44B3F;
    border-color: #C44B3F;
    color: white;
}
.btn-danger:hover {
    background: #A33D33;
}
.btn-success {
    background: #E0F0E8;
    border-color: #1B6B52;
    color: #145A44;
}
.btn-success:hover {
    background: #D0E8DA;
}
.btn:active {
    transform: translateY(1px);
    box-shadow: inset 0 1px 2px rgba(20,46,40,0.15);
}

.layers-list label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-bottom: 4px;
    cursor: pointer;
}

/* Group layers list (personal/shared) */
.layer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #D6CFC5;
    border-radius: 14px;
    margin-bottom: 6px;
    background: #FFFDF8;
    cursor: pointer;
    transition: background 0.15s;
}
.layer-row:hover {
    background: #F0EBE3;
}

.layer-row .left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.layer-row .name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-row .meta {
    font-size: 12px;
    color: #6B8F7F;
    white-space: nowrap;
}

.layer-row .right {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.layers-list input[type="checkbox"] {
    margin: 0;
    accent-color: #1B6B52;
}
.hint {
    font-size: 12px;
    color: #6B8F7F;
    margin-top: 4px;
}

.map-wrapper {
    position: relative;
}

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

/* M2: safe area для map controls — кнопки не за нотчем/home indicator */
.maplibregl-ctrl-bottom-right {
    right: env(safe-area-inset-right, 0px);
    bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== Фото-галерея (lightbox) ===== */
.mm-photo-modal {
    position: fixed;
    inset: 0;
    background: rgba(20,46,40,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.mm-gallery-close {
    position: absolute;
    top: 12px;
    /* M2: safe area — кнопка не за камерой/нотчем */
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 16px;
    right: calc(16px + env(safe-area-inset-right, 0px));
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: background 0.15s;
}
.mm-gallery-close:hover { background: rgba(255,255,255,0.3); }

.mm-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: background 0.15s;
}
.mm-gallery-arrow:hover { background: rgba(255,255,255,0.3); }
.mm-gallery-prev { left: 12px; left: calc(12px + env(safe-area-inset-left, 0px)); }
.mm-gallery-next { right: 12px; right: calc(12px + env(safe-area-inset-right, 0px)); }

.mm-gallery-img {
    max-width: calc(100% - 120px);
    max-height: calc(100vh - 100px);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(20,46,40,0.5);
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

@media (max-width: 600px) {
    .mm-gallery-arrow { width: 36px; height: 36px; font-size: 18px; }
    .mm-gallery-prev { left: 6px; left: calc(6px + env(safe-area-inset-left, 0px)); }
    .mm-gallery-next { right: 6px; right: calc(6px + env(safe-area-inset-right, 0px)); }
    .mm-gallery-img { max-width: calc(100% - 80px); border-radius: 6px; }
}

/* ===== Превью выбранных фото ===== */
.mm-preview-item {
    position: relative;
    width: 56px;
    height: 56px;
}
.mm-preview-item img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #D6CFC5;
}
.mm-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: #D97B5C;
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}
.mm-preview-remove:hover { background: #C44B3F; }


.maplibregl-popup-content {
    max-width: 350px;
    background: #FFFDF8;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(20,46,40,0.15);
}
/* Убрать focus ring при программном открытии попапа — оставить только для клавиатурной навигации */
.maplibregl-popup-content button:focus:not(:focus-visible),
.maplibregl-popup-content a:focus:not(:focus-visible){
    outline:none;
}

.mm-popup {
    max-width: 300px;
    min-width: 200px;
    max-height: 350px;
    overflow-y: auto;
}

.mm-popup-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 2px;
    overflow-wrap: break-word;
    color: #142E28;
}

.mm-popup-note {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    line-height: 1.35;
    font-size: 13px;
    color: #2D5A4A;
    margin-top: 6px;
}

/* ===== Mobile (Фаза 5) ===== */
/* M3: landscape + max-height:500px ловит iPhone 13+/14/15/16 в ландшафте (ширина > 800px) */
@media (max-width: 800px), (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .app.guest-mode {
        grid-template-rows: 1fr;
    }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid #D6CFC5;
        /* C3: svh не сжимается при клавиатуре */
        max-height: 40vh;
        max-height: 40svh;
        /* M6: overflow:visible — ручка-пилюля выступает за границу sidebar */
        overflow: visible;
        position: relative;
        z-index: 2;
        /* Сброс десктопных стилей */
        width: auto;
        transition: none;
    }
    .sidebar-tab {
        font-size: 12px;
        padding: 8px 4px;
    }
    .app-header {
        padding: 0 12px;
        /* M2: safe area для мобильного landscape */
        padding: 0 calc(12px + env(safe-area-inset-right, 0px)) 0 calc(12px + env(safe-area-inset-left, 0px));
    }
    .modal{
        max-height:calc(100vh - 48px);
        max-height:calc(100dvh - 48px);
    }
    /* M6: ручка-пилюля для сворачивания sidebar (мобильный вид) */
    .sidebar-handle {
        /* Переопределение десктопных стилей на горизонтальную пилюлю внизу */
        top: auto;
        right: 28%;
        bottom: 0;
        transform: translateY(100%);
        width: 44px;
        height: 18px;
        border: 1px solid #D6CFC5;
        border-top: none;
        border-left: 1px solid #D6CFC5;
        border-radius: 0 0 10px 10px;
        box-shadow: 0 2px 4px rgba(20,46,40,0.08);
    }
    .sidebar-handle svg {
        /* Сброс десктопного rotate(-90deg) — мобильный шеврон по умолчанию вверх */
        transform: none;
    }
    /* M6: collapsed — sidebar свёрнут, видна только ручка */
    .sidebar.collapsed #authed-only {
        display: none;
    }
    .sidebar.collapsed {
        border-bottom: none;
        max-height: none;
        /* Сброс десктопного width:0 — на мобильных sidebar full-width */
        width: auto;
    }
    .sidebar.collapsed .sidebar-handle svg {
        transform: rotate(180deg);
    }
}

/* W13: Landscape mode — sidebar не занимает слишком много */
@media (orientation: landscape) and (max-width: 800px), (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
    .sidebar {
        max-height: 40vh;
        max-height: 40svh;
        /* M2: safe area для sidebar в landscape */
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
}

/* Скроллируемый список внутри карточки sidebar */
.scrollable-list {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
}

.mm-modal { position: fixed; inset:0; background: rgba(20,46,40,0.5); display:flex; align-items:center; justify-content:center; z-index:10000; }
.mm-modal-card { width:min(520px, 92vw); background:#FFFDF8; border-radius:12px; padding:14px; box-shadow: 0 12px 40px rgba(20,46,40,0.25); }
.mm-modal-title { font-weight:600; margin-bottom:10px; color:#142E28; }
.mm-modal-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:10px; }


.icon-btn{
  border:1px solid #D6CFC5;
  background:#FFFDF8;
  border-radius:10px;
  padding:6px 8px;
  cursor:pointer;
  line-height:1;
  position:relative;
}
.icon-btn:hover{ background:#F0EBE3; }

.badge{
  position:absolute;
  top:-6px;
  right:-6px;
  min-width:18px;
  height:18px;
  padding:0 6px;
  border-radius:999px;
  background:#D97B5C;
  color:#ffffff;
  font-size:12px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:2px solid #142E28;
}

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

.list-item{
  border:1px solid #D6CFC5;
  border-radius:12px;
  padding:8px 10px;
  background:#FFFDF8;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.list-item .meta{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}
.list-item .title{
  font-weight:600;
  font-size:13px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  color:#142E28;
}
.list-item .sub{
  font-size:12px;
  color:#6B8F7F;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.list-item .actions{
  display:flex;
  gap:6px;
  align-items:center;
  flex-shrink:0;
}

.divider{
  height:1px;
  background:#D6CFC5;
}

.modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(20,46,40,0.5);
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:24px 12px;
  z-index:9999;
  overflow-y:auto;
}

.modal{
  width:min(520px, 100%);
  max-height:calc(100vh - 48px);
  max-height:calc(100dvh - 48px);
  overflow-y:auto;
  background:#FFFDF8;
  border-radius:16px;
  box-shadow:0 20px 60px rgba(20,46,40,0.25);
  border:1px solid #D6CFC5;
  flex-shrink:0;
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 12px;
  border-bottom:1px solid #D6CFC5;
}
.modal-title{
  font-weight:700;
  font-size:14px;
  color:#142E28;
}
.modal-body{
  padding:12px;
}

/* Выпадающее меню «⋯» в попапе точки */
.mm-popup-menu{
  position:relative;
  display:inline-block;
}
.mm-popup-menu-btn{
  background:transparent;
  border:none;
  cursor:pointer;
  font-size:18px;
  line-height:1;
  padding:2px 6px;
  border-radius:6px;
  color:#6B8F7F;
  outline:none;
}
.mm-popup-menu-btn:hover{
  background:#F0EBE3;
}
.mm-popup-menu-btn:focus-visible{
  outline:none;
}
.mm-popup-dropdown{
  display:none;
  position:absolute;
  right:0;
  top:100%;
  min-width:160px;
  background:#FFFDF8;
  border:1px solid #D6CFC5;
  border-radius:10px;
  box-shadow:0 8px 24px rgba(20,46,40,0.15);
  z-index:100;
  padding:4px 0;
}
/* Dropdown в комментариях — fixed, чтобы не обрезался overflow контейнера */
.comment-actions .mm-popup-dropdown{
  position:fixed;
  right:auto;
  top:auto;
  z-index:10000;
}
.mm-popup-dropdown.open{
  display:block;
}
.mm-popup-dropdown-item{
  display:block;
  width:100%;
  padding:8px 14px;
  border:none;
  background:transparent;
  text-align:left;
  cursor:pointer;
  font-size:13px;
  color:#C44B3F;
}
.mm-popup-dropdown-item:hover{
  background:#FDF0EE;
}

/* Плашка жалобы в попапе */
.mm-report-badge{
  margin-top:4px;
  padding:4px 8px;
  border-radius:6px;
  font-size:11px;
  line-height:1.3;
}
.mm-report-badge--pending{
  background:#F0EBE3;
  color:#6B8F7F;
}
.mm-report-badge--reported{
  background:#FDF0EE;
  color:#C44B3F;
}

/* Жалобы в панели модерации */
.mm-report-line{
  font-size:12px;
  color:#C44B3F;
  margin-top:2px;
  overflow-wrap:break-word;
  word-break:break-word;
}
.mm-report-line.collapsed{
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.mm-report-toggle{
  font-size:11px;
  color:#6B8F7F;
  cursor:pointer;
  border:none;
  background:none;
  padding:0;
  margin-top:2px;
}

/* Кнопка комментариев в попапе */
.mm-comments-btn{
  display:inline-flex;
  align-items:center;
  gap:4px;
  margin-top:6px;
  padding:4px 10px;
  border-radius:9999px;
  border:1px solid #C5B9A8;
  background:#F0EBE3;
  font-size:12px;
  cursor:pointer;
  color:#2D5A4A;
}
.mm-comments-btn:hover{
  background:#E0D8CE;
}

/* Список комментариев в модалке */
.comments-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.comment-item{
  border:1px solid #D6CFC5;
  border-radius:12px;
  padding:8px 10px;
  background:#FFF8F0;
  position:relative;
}
.comment-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:4px;
}
.comment-author{
  font-size:13px;
  font-weight:600;
  color:#2D5A4A;
  max-width:200px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.comment-time{
  font-size:11px;
  color:#8FA89C;
  cursor:default;
}
.comment-text{
  font-size:13px;
  line-height:1.4;
  white-space:pre-wrap;
  overflow-wrap:break-word;
  color:#1A3A32;
}
.comment-toggle-text{
  background:none;
  border:none;
  color:#6B8F7F;
  font-size:12px;
  cursor:pointer;
  padding:0;
  margin-top:2px;
  display:inline-block;
}
.comment-toggle-text:hover{
  color:#2D5A4A;
}
.comment-delete-btn{
  background:transparent;
  border:none;
  cursor:pointer;
  font-size:16px;
  color:#8FA89C;
  padding:2px 4px;
  border-radius:6px;
  line-height:1;
}
.comment-delete-btn:hover{
  background:#FDF0EE;
  color:#C44B3F;
}

/* Нейтральный пункт меню (Редактировать, Ответить) */
.mm-popup-dropdown-item--default{
  color:#2D5A4A;
}
.mm-popup-dropdown-item--default:hover{
  background:#F0EBE3;
}

/* Ответ-комментарий — отступ и левый бордер */
.comment-item--reply{
  margin-left:24px;
  border-left:3px solid #D6CFC5;
  border-radius:0 12px 12px 0;
}
/* Подсветка комментария при переходе из уведомления */
.comment-highlight{
  animation: comment-flash 2s ease-out;
}
@keyframes comment-flash{
  0%{background-color:#D4E8C2;}
  100%{background-color:transparent;}
}

/* Метка «↩ @автор» у ответов */
.comment-reply-to{
  font-size:12px;
  color:#6B8F7F;
  margin-bottom:2px;
  cursor:pointer;
}
.comment-reply-to:hover{
  color:#1B6B52;
}

/* «(изменено)» серым курсивом */
.comment-edited{
  font-size:11px;
  color:#8FA89C;
  font-style:italic;
  margin-left:4px;
}

/* Inline-редактирование */
.comment-edit-area{
  width:100%;
  padding:4px 6px;
  border:1px solid #C5B9A8;
  border-radius:6px;
  font-size:13px;
  resize:vertical;
  min-height:40px;
  max-height:200px;
  overflow-y:auto;
  outline:none;
  background:#FFFDF8;
}
.comment-edit-area:focus{
  border-color:#1B6B52;
}
.comment-edit-actions{
  display:flex;
  gap:6px;
  margin-top:4px;
  justify-content:flex-end;
}

/* Строка действий под текстом комментария */
.comment-actions{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:4px;
  font-size:12px;
  color:#8FA89C;
}

/* Кнопка «Ответить» под комментарием */
.comment-reply-btn{
  background:none;
  border:none;
  cursor:pointer;
  font-size:12px;
  color:#6B8F7F;
  font-weight:600;
  padding:0;
}
.comment-reply-btn:hover{
  color:#2D5A4A;
}

/* «Просмотреть N ответов» */
.comment-replies-toggle{
  background:none;
  border:none;
  cursor:pointer;
  font-size:12px;
  color:#6B8F7F;
  padding:4px 0 4px 24px;
  display:flex;
  align-items:center;
  gap:6px;
}
.comment-replies-toggle:hover{
  color:#2D5A4A;
}
.comment-replies-toggle::before{
  content:"";
  display:inline-block;
  width:24px;
  height:1px;
  background:#C5B9A8;
}

/* Уведомления в модалке колокольчика */
.notif-section{
  margin-top:0;
}
.notif-item{
  padding:8px 10px;
  border-radius:10px;
  border:1px solid #D6CFC5;
  background:#FFFDF8;
  margin-bottom:6px;
  cursor:pointer;
  transition:background 0.1s;
}
.notif-item:hover{
  background:#F0EBE3;
}
.notif-item--unread{
  background:#E0F0E8;
  border-color:#A8D4BE;
}
.notif-item--unread:hover{
  background:#D0E8D8;
}
.notif-text{
  font-size:13px;
  line-height:1.4;
  color:#1A3A32;
  overflow-wrap:break-word;
}
.notif-time{
  font-size:11px;
  color:#8FA89C;
  margin-top:2px;
}
.notif-read-all-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:4px 12px;
  border-radius:9999px;
  border:1px solid #C5B9A8;
  background:#F0EBE3;
  font-size:12px;
  cursor:pointer;
  margin-bottom:8px;
  color:#2D5A4A;
}
.notif-read-all-btn:hover{
  background:#E0D8CE;
}

/* Индикатор ответа в инпуте */
.comment-reply-indicator{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:4px 8px;
  background:#E0F0E8;
  border-radius:8px 8px 0 0;
  border:1px solid #A8D4BE;
  border-bottom:none;
  font-size:12px;
  color:#1B6B52;
}
.comment-reply-indicator button{
  background:none;
  border:none;
  cursor:pointer;
  font-size:14px;
  color:#6B8F7F;
  padding:0 2px;
  line-height:1;
}
.comment-reply-indicator button:hover{
  color:#142E28;
}

/* Кластеры маркеров */
.mm-cluster-marker{
  background:rgba(27,107,82,0.85);
  color:#fff;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:12px;
  font-weight:600;
  border:2px solid #fff;
  box-shadow:0 2px 6px rgba(20,46,40,0.3);
  cursor:pointer;
}

/* Spinner загрузки в галерее */
.mm-gallery-spinner{
  position:absolute;
  top:50%;
  left:50%;
  margin:-16px 0 0 -16px;
  width:32px;
  height:32px;
  border:3px solid rgba(255,255,255,0.3);
  border-top-color:#fff;
  border-radius:50%;
  animation:mm-spin 0.6s linear infinite;
}
@keyframes mm-spin{ to{ transform:rotate(360deg); } }
.mm-gallery-error{
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
  color:rgba(255,255,255,0.7);
  font-size:16px;
  text-align:center;
}

/* ===== Плавающая кнопка слоёв на карте ===== */
.mm-layers-float{
  position:relative;
}
.mm-layers-float-btn{
  width:29px;
  height:29px;
  padding:0;
  border:none;
  background:#FFFDF8;
  border-radius:4px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 0 0 2px rgba(20,46,40,0.1);
}
.mm-layers-float-btn:hover{
  background:#F0EBE3;
}
.mm-layers-float-btn svg{
  width:17px;
  height:17px;
  stroke:#2D5A4A;
  fill:none;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.mm-layers-float-dropdown{
  display:none;
  position:absolute;
  bottom:calc(100% + 6px);
  right:0;
  min-width:220px;
  max-height:min(320px, 50vh);
  overflow-y:auto;
  background:#FFFDF8;
  border:1px solid #D6CFC5;
  border-radius:12px;
  box-shadow:0 8px 24px rgba(20,46,40,0.15);
  z-index:100;
  padding:6px 0;
}
.mm-layers-float-dropdown.open{
  display:block;
}
.mm-layers-float-section{
  padding:4px 12px 2px;
  font-size:11px;
  font-weight:600;
  text-transform:uppercase;
  color:#6B8F7F;
  letter-spacing:0.04em;
}
.mm-layers-float-divider{
  height:1px;
  background:#D6CFC5;
  margin:4px 0;
}
.mm-layers-float-item{
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 12px;
  font-size:13px;
  cursor:pointer;
  min-width:0;
}
.mm-layers-float-item:hover{
  background:#F0EBE3;
}
.mm-layers-float-item input[type="checkbox"]{
  margin:0;
  accent-color:#1B6B52;
  flex-shrink:0;
}
.mm-layers-float-name{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  min-width:0;
}

/* ===== Иконка видимости слоя в сайдбаре ===== */
.layer-eye{
  cursor:pointer;
  width:28px;
  height:28px;
  padding:4px;
  margin:-4px;
  border-radius:4px;
  color:#6B8F7F;
  flex-shrink:0;
  transition:color 0.15s;
}
.layer-eye:hover{ color:#142E28; }
.layer-eye-off{ color:#C5D1CC; }
.layer-eye-off:hover{ color:#8FA89C; }

/* ===== Панель карточек слоя ===== */
.layer-cards-panel{
  position:fixed;
  top:48px;      /* высота header */
  left:280px;    /* ширина sidebar */
  bottom:0;
  width:300px;
  background:#FAF6F0;
  border-right:1px solid #D6CFC5;
  box-shadow:4px 0 12px rgba(20,46,40,0.08);
  z-index:50;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  /* Синхронно с анимацией sidebar */
  transition:left 0.15s ease;
}
/* При свёрнутом sidebar панель прижимается к левому краю */
.sidebar.collapsed ~ .layer-cards-panel{
  left:0;
}
.layer-cards-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid #D6CFC5;
  flex-shrink:0;
}
.layer-cards-title{
  font-weight:600;
  font-size:15px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#142E28;
}
.layer-cards-list{
  flex:1;
  overflow-y:auto;
  padding:8px;
}
.layer-place-card{
  padding:12px;
  border-radius:8px;
  cursor:pointer;
  transition:background 0.15s;
}
.layer-place-card:hover{ background:#F0EBE3; }
.layer-place-card + .layer-place-card{ border-top:1px solid #E8E0D4; }
.layer-place-card-title{
  font-weight:500;
  font-size:14px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#142E28;
}
.layer-place-card-note{
  font-size:12px;
  color:#6B8F7F;
  margin-top:2px;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.layer-place-card-author{
  font-size:11px;
  color:#8FA89C;
  margin-top:4px;
}
.layer-place-card-thumb{
  width:48px;
  height:48px;
  object-fit:cover;
  border-radius:6px;
  flex-shrink:0;
  border:1px solid #D6CFC5;
}

/* Мобильный: панель заменяет сайдбар */
@media (max-width:800px), (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .layer-cards-panel{
    left:0;
    width:100%;
    top:48px;
    bottom:auto;
    max-height:45vh;
    max-height:45svh;
    border-right:none;
    border-bottom:1px solid #D6CFC5;
    border-radius:0;
    box-shadow:0 4px 12px rgba(20,46,40,0.1);
    /* M2: safe area для landscape — заголовок и кнопка закрытия не за нотчем */
    padding-left:env(safe-area-inset-left, 0px);
    padding-right:env(safe-area-inset-right, 0px);
  }
  .app.layer-panel-open .sidebar{ display:none; }
}

/* Гость не видит панель */
.app.guest-mode .layer-cards-panel{ display:none !important; }

/* ===== Бейдж слоя в попапе ===== */
.mm-layer-badge{
  display:inline-block;
  font-size:11px;
  padding:1px 8px;
  border-radius:9999px;
  background:#E8F0ED;
  color:#1B6B52;
  white-space:nowrap;
  max-width:140px;
  overflow:hidden;
  text-overflow:ellipsis;
  vertical-align:middle;
}
/* Метаданные попапа (автор + бейдж) */
.mm-popup-meta{
  margin-top:0;
  margin-bottom:2px;
  font-size:11px;
  color:#6B8F7F;
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
  overflow-wrap:break-word;
}

/* ===== Компактный попап: inline «Развернуть» ===== */
.mm-popup-expand{
  border:none;
  background:none;
  color:#1B6B52;
  font-size:12px;
  font-weight:600;
  cursor:pointer;
  padding:0;
  white-space:nowrap;
  text-decoration:underline;
  text-decoration-color:rgba(27,107,82,0.4);
  text-underline-offset:2px;
}
.mm-popup-expand:hover{ text-decoration-color:#1B6B52; }

/* ===== Компактный попап: сетка фото ===== */
.mm-popup-photos{
  margin-top:6px;
  display:flex;
  flex-wrap:nowrap;
  gap:4px;
}
.mm-photo-more{
  width:36px;
  height:56px;
  border-radius:6px;
  background:#E8F0ED;
  color:#1B6B52;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:13px;
  font-weight:600;
  cursor:pointer;
  flex-shrink:0;
}
.mm-photo-more:hover{ background:#D6E8E0; }
