/* ==========================================================
   БАЗА
   ========================================================== */

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
}

button,
input,
select,
textarea {
    box-sizing: border-box;
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

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

/* Небольшое аппаратное сглаживание помогает браузеру
   не показывать субпиксельные швы между растровыми тайлами. */
.leaflet-tile {
    backface-visibility: hidden;
}


/* ==========================================================
   КООРДИНАТЫ
   ========================================================== */

#coordinates {
    position: fixed;
    top: 10px;
    left: 48px;
    right: auto;
    bottom: auto;

    padding: 6px 10px;

    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #999;

    font-family: monospace;
    font-size: 14px;

    z-index: 1000;

    white-space: nowrap;
}


/* ==========================================================
   ОБЩАЯ ПАНЕЛЬ УПРАВЛЕНИЯ
   ========================================================== */

#right-ui-panel {
    position: fixed;
    top: 10px;
    right: 20px;

    z-index: 1000;

    width: 240px;
    max-height: calc(100vh - 70px);

    display: flex;
    flex-direction: column;
    gap: 10px;

    overflow-y: auto;
    overflow-x: visible;

    box-sizing: border-box;
}

#right-ui-panel > * {
    flex: 0 0 auto;
}

/* ==========================================================
   МЕНЕДЖЕР СЛОЁВ
   ========================================================== */
.map-layer-panel {
    padding: 0;
    overflow: hidden;
}
.map-layer-panel > summary {
    padding: 11px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    list-style-position: inside;
    user-select: none;
}
.map-layer-panel > summary:hover { background: #f4f5f6; }
.map-layer-panel[open] > summary { border-bottom: 1px solid #e5e5e5; }
.map-layer-panel-content { padding: 7px 12px 11px; }
.map-layer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 13px;
    cursor: pointer;
}
.map-layer-row input { margin: 0; accent-color: #526677; }
.map-layer-separator { height: 1px; background: #e4e4e4; margin: 5px 0; }
.map-layer-hint { font-size: 11px; line-height: 1.35; color: #73787d; margin-top: 6px; }
.area-label-settings-title {
    font-size: 12px;
    font-weight: 700;
    margin: 8px 0;
    color: #3b4550;
}
.area-label-mode-row {
    display: block;
    font-size: 12px;
    margin: 8px 0;
    color: #414a53;
}
.area-label-mode-row span { display: block; margin-bottom: 4px; }
.area-label-mode-row select {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 7px 5px;
    border: 1px solid #c5c9ce;
    border-radius: 4px;
    background: white;
    font-size: 11px;
    color: #333;
}
.area-label-mode-row select:disabled { opacity: 0.6; }
#area-kind { width: 100%; box-sizing: border-box; padding: 7px; }
.area-card-layer { font-size: 12px; color: #707780; margin: 0 0 9px; }

/* Временная шкала общая для мастера и игрока: map-timeline.css */

/* ==========================================================
   ИЗОБРАЖЕНИЕ ЛОКАЦИИ
   ========================================================== */

.location-image-field {
    margin-bottom: 15px;
}

.location-image-title {
    margin-bottom: 6px;
    font-size: 14px;
}

.location-image-controls {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
}

.location-image-controls button {
    padding: 7px 10px;
    background: white;
    border: 1px solid #999;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
}

.location-image-controls button:hover:not(:disabled) {
    background: #f0f0f0;
}

.location-image-controls button:disabled {
    opacity: 0.45;
    cursor: default;
}

.location-image-name {
    min-height: 16px;
    margin-bottom: 6px;
    color: #666;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-image-path {
    margin-top: 0 !important;
}

.location-image-preview {
    width: 100%;
    margin-top: 8px;
    padding: 6px;
    background: #f3f3f3;
    border: 1px solid #ddd;
    border-radius: 3px;
    box-sizing: border-box;
}

.location-image-preview img {
    display: block;
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    background: white;
}

@media (max-height: 760px) {

    .form-window {
        max-height: calc(100vh - 24px);
        padding: 18px;
    }

    .location-image-preview img {
        max-height: 130px;
    }

}

/* ==========================================================
   ВРЕМЯ СУЩЕСТВОВАНИЯ ОБЪЕКТА
   ========================================================== */

.object-history-fields {
    margin-top: 16px;
    padding: 10px;
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 4px;
}


.object-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 9px;
}

.object-history-title {
    font-size: 14px;
    font-weight: 600;
}

.object-history-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
}

.object-history-actions button {
    padding: 5px 8px;
    background: white;
    border: 1px solid #aaa;
    border-radius: 3px;
    font-size: 11px;
}

.object-history-actions button:hover:not(:disabled) {
    background: #f0f0f0;
}

.object-history-actions button:disabled {
    opacity: 0.45;
    cursor: default;
}

.object-history-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 150px;
    margin-bottom: 10px;
    overflow-y: auto;
}

.object-history-period {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "name time"
        "status time";
    align-items: center;
    gap: 2px 10px;
    width: 100%;
    padding: 7px 9px;
    background: white;
    border: 1px solid #d2d2d2;
    border-radius: 4px;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
}

.object-history-period:hover {
    background: #f1f1f1;
}

.object-history-period.is-selected {
    border-color: #7f8b95;
    box-shadow: inset 3px 0 0 rgba(70, 90, 110, 0.65);
}

.object-history-period.is-current {
    background: #fafafa;
}

.object-history-period-name {
    grid-area: name;
    min-width: 0;
    overflow: hidden;
    color: #333;
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.object-history-period-time {
    grid-area: time;
    align-self: center;
    color: #686868;
    font-size: 10px;
    white-space: nowrap;
}

.object-history-period-status {
    grid-area: status;
    min-height: 12px;
    color: #777;
    font-size: 9px;
}

.object-history-period-status.is-current {
    color: #4f6d82;
}

.object-history-current-title {
    margin: 5px 0 7px;
    color: #555;
    font-size: 11px;
    font-weight: 600;
}


.object-time-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.object-time-boundary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 76px;
    grid-template-areas:
        "heading heading"
        "era year";
    gap: 5px 6px;
    min-width: 0;
}

.object-time-boundary-title {
    grid-area: heading;
    margin: 0;
    color: #666;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.object-time-boundary select {
    grid-area: era;
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
}

.object-time-boundary input {
    grid-area: year;
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
}

.object-time-boundary input:disabled {
    background: #ededed;
    color: #999;
}

.location-card-time {
    white-space: pre-line;
}

.control-panel {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;

    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #999;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);

    font-family: Arial, sans-serif;
}

#location-search,
#map-object-filter,
#location-filter,
#location-type-filter {
    display: block;

    width: 100%;
    margin-bottom: 8px;
    padding: 8px;

    font-size: 14px;
}


#location-filter-group,
#map-type-filter-group {
    width: 100%;
}

#location-filter-group[hidden],
#map-type-filter-group[hidden] {
    display: none;
}

#clear-location-filter {
    width: 100%;
    padding: 7px;

    background: white;
    border: 1px solid #999;
}

#clear-location-filter:hover,
.modal-actions button:hover,
.form-actions button:hover,
.area-geometry-actions button:hover,
.location-rotation-controls button:hover {
    background: #eee;
}


/* ==========================================================
   РИСОВАНИЕ ДОРОГ И ОБЛАСТЕЙ
   ========================================================== */

#map-drawing-controls {
    width: 100%;
    box-sizing: border-box;
}

.map-drawing-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#edit-mode-button,
#draw-road-button,
#draw-area-button {
    display: block;
    width: 240px;
    padding: 10px 14px;

    background: white;
    border: 1px solid #999;

    font-size: 14px;
    text-align: left;
}

#edit-mode-button.active,
#draw-road-button.active,
#draw-area-button.active {
    background: #333;
    color: white;
}

#edit-submode-controls {
    width: 240px;
    box-sizing: border-box;
}

.edit-submode-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.edit-submode-buttons button {
    min-width: 0;
    padding: 8px 6px;
    background: white;
    border: 1px solid #999;
    font-size: 13px;
}

.edit-submode-buttons button.active {
    background: #333;
    color: white;
}

.edit-mode-hint {
    box-sizing: border-box;
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;

    background: #f7f7f7;
    border: 1px solid #ddd;

    font-size: 12px;
    line-height: 1.4;
    color: #555;

    white-space: normal;
    overflow-wrap: anywhere;
}

#edit-road-controls,
#edit-area-controls {
    margin-top: 8px;
}

#edit-road-controls #draw-road-button,
#edit-area-controls #draw-area-button {
    width: 100%;
}

/* Категория выбирается до того, как появится первый узел полигона. */
.area-create-kind {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin-bottom: 8px;
    padding: 10px;
    background: white;
    border: 1px solid #999;
    font-size: 13px;
}

#area-draw-kind {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 6px;
    padding: 6px;
    font-size: 13px;
}

#area-draw-kind:disabled {
    opacity: 0.65;
}

#road-options {
    box-sizing: border-box;
    width: 100%;
    margin-top: 8px;
    padding: 10px;

    background: white;
    border: 1px solid #999;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

#road-options label {
    display: block;
    font-size: 13px;
}

#road-type {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 6px;
}

/* Подсказка для навигации ПКМ при рисовании длинной дороги. */
.road-navigation-hint {
    margin: 9px 0 0;
    padding-top: 8px;
    border-top: 1px solid #e4e4e4;
    font-size: 11px;
    line-height: 1.45;
    color: #59646e;
}

.road-navigation-hint.awaiting-resume {
    color: #8b4c15;
    font-weight: 600;
}

/* В режиме редактирования положение точки показывает собственное
   перекрестье с направляющими. Системный курсор Leaflet не должен
   появляться ни на SVG-полигонах, ни на широких hitLine дорог,
   ни на вершинах, маркерах и во время перетаскивания карты.
   Правила касаются только карты: кнопки зума и панели не затронуты. */
#map.edit-mode,
#map.edit-mode.leaflet-grab,
#map.edit-mode.leaflet-dragging,
#map.edit-mode.leaflet-dragging .leaflet-grab,
#map.edit-mode .leaflet-pane,
#map.edit-mode .leaflet-pane * {
    cursor: none !important;
}

/* В режиме просмотра все интерактивные объекты карты
   (дороги, полигоны, подписи областей и маркеры) используют
   одну и ту же руку-указатель. В редакторе выше действует
   отдельное правило cursor: none для нашего перекрестья. */
#map:not(.edit-mode) .leaflet-interactive,
#map:not(.edit-mode) .dragon-area-label-icon,
#map:not(.edit-mode) .dragon-area-label-icon * {
    cursor: pointer !important;
}

/* Два независимых SVG pane: верхний биом не должен блокировать
   лорные территории в местах, где биома нет. Кликами управляют
   только сами залитые полигоны, не пустые контейнеры pane. */
#map .leaflet-area-pane,
#map .leaflet-biome-pane {
    pointer-events: none;
}

#map .leaflet-area-pane path.leaflet-interactive,
#map .leaflet-biome-pane path.leaflet-interactive {
    pointer-events: all;
}

/* ==========================================================
   КУРСОР РЕДАКТОРА + КООРДИНАТНЫЕ НАПРАВЛЯЮЩИЕ
   ========================================================== */

.edit-cursor-overlay {
    --edit-cursor-x: 0px;
    --edit-cursor-y: 0px;

    position: absolute;
    inset: 0;

    z-index: 900;
    pointer-events: none;

    display: none;
}

.edit-cursor-overlay.active {
    display: block;
}

.edit-cursor-guide {
    position: absolute;
    pointer-events: none;

    opacity: 0.7;

    filter:
        drop-shadow(
            0 0 1px
            rgba(255, 255, 255, 0.65)
        );
}

.edit-cursor-guide-x {
    left: 0;
    right: 0;
    top: var(--edit-cursor-y);

    border-top:
        1px dashed
        rgba(45, 45, 45, 0.42);
}

.edit-cursor-guide-y {
    top: 0;
    bottom: 0;
    left: var(--edit-cursor-x);

    border-left:
        1px dashed
        rgba(45, 45, 45, 0.42);
}

.edit-cursor-reticle {
    position: absolute;
    left: var(--edit-cursor-x);
    top: var(--edit-cursor-y);

    width: 16px;
    height: 16px;

    transform: translate(-50%, -50%);

    box-sizing: border-box;
    border: 1.5px solid rgba(35, 35, 35, 0.9);
    border-radius: 50%;

    background: rgba(255, 255, 255, 0.08);

    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.9),
        0 1px 4px rgba(0, 0, 0, 0.35);
}

.edit-cursor-reticle::before,
.edit-cursor-reticle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;

    background: rgba(35, 35, 35, 0.9);

    transform: translate(-50%, -50%);
}

.edit-cursor-reticle::before {
    width: 2px;
    height: 24px;
}

.edit-cursor-reticle::after {
    width: 24px;
    height: 2px;
}

.edit-cursor-dot {
    position: absolute;
    left: 50%;
    top: 50%;

    width: 3px;
    height: 3px;

    transform: translate(-50%, -50%);

    border-radius: 50%;
    background: #222;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.9);

    z-index: 2;
}


/* ==========================================================
   ЧЕКБОКСЫ ОБЛАСТЕЙ
   ========================================================== */

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.checkbox-label.hidden {
    display: none !important;
}

.checkbox-label input {
    width: auto;
    margin: 0;
}


/* ==========================================================
   ОБЩИЕ MODAL
   ========================================================== */

.modal {
    position: fixed;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.45);

    z-index: 2000;
}

#location-card,
#road-card,
#area-card {
    z-index: 3000;
}

.modal-window {
    box-sizing: border-box;

    background: white;
    border: 1px solid #888;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);

    font-family: Arial, sans-serif;
}

.form-window {
    width: 380px;
    max-width: calc(100% - 40px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    box-sizing: border-box;
}

.card-window {
    position: relative;

    width: 520px;
    max-width: calc(100% - 40px);
    max-height: calc(100% - 40px);

    overflow-y: auto;
    padding: 30px;
}

.modal-window h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.card-window h2 {
    margin-bottom: 5px;
    padding-right: 35px;
    font-size: 28px;
}

.modal-window label {
    display: block;
    margin-bottom: 15px;
    font-size: 14px;
}

.modal-window input[type="text"],
.modal-window select,
.modal-window textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 8px;
    font-size: 14px;
}

.modal-window textarea {
    resize: vertical;
}

.modal-actions,
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions button,
.form-actions button {
    padding: 8px 16px;
    background: white;
    border: 1px solid #999;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;

    width: 32px;
    height: 32px;

    border: none;
    background: transparent;

    font-size: 28px;
    line-height: 28px;
}

.modal-close:hover {
    background: #eee;
}


/* ==========================================================
   КООРДИНАТЫ / КАРТОЧКИ
   ========================================================== */

.location-coordinates,
.location-card-coordinates {
    display: flex;
    gap: 30px;

    margin-top: 20px;
    margin-bottom: 20px;
    padding: 10px;

    background: #f3f3f3;
    font-family: monospace;
}

.location-card-coordinates {
    gap: 40px;
    margin-top: 0;
    padding: 12px;
}

.location-card-type {
    margin-bottom: 25px;
    color: #666;
    font-size: 15px;
}

.location-card-description {
    margin-bottom: 25px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.location-card-extra {
    margin-bottom: 25px;
    padding: 12px;
    background: #f3f3f3;
    line-height: 1.6;
}


/* ==========================================================
   ИЗОБРАЖЕНИЕ ЛОКАЦИИ
   ========================================================== */

.location-card-image {
    width: 100%;
    margin-bottom: 25px;
    text-align: center;
}

.location-card-image img {
    display: block;
    width: 100%;
    max-height: 300px;
    object-fit: contain;
}


/* ==========================================================
   ИКОНКИ ЛОКАЦИЙ
   ========================================================== */

/* ==========================================================
   ОРИЕНТАЦИЯ МОСТОВ И ТОННЕЛЕЙ
   ========================================================== */

.location-rotation {
    margin-bottom: 15px;
}

.location-rotation.hidden {
    display: none;
}

.location-rotation-title {
    margin-bottom: 8px;
    font-size: 14px;
}

.location-rotation-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-rotation-controls button {
    flex-shrink: 0;
    padding: 6px 9px;
    background: white;
    border: 1px solid #999;
}

.location-rotation-controls input[type="range"] {
    flex: 1;
    min-width: 100px;
}

.location-rotation-value {
    margin-top: 5px;
    text-align: center;
    font-size: 13px;
    color: #555;
}


/* ==========================================================
   ПОДПИСИ ОБЛАСТЕЙ
   ========================================================== */

/* ==========================================================
   ПРАВАЯ КОЛОНКА ИНТЕРФЕЙСА
   ========================================================== */

#right-ui-panel::-webkit-scrollbar {
    width: 7px;
}

#right-ui-panel::-webkit-scrollbar-thumb {
    background: rgba(80, 80, 80, 0.35);
    border-radius: 4px;
}

@media (max-width: 900px) {
    #right-ui-panel {
        top: 10px;
    }

    #coordinates {
        top: 68px;
        left: 10px;
    }
}

@media (max-width: 520px) {
    #right-ui-panel {
        left: 10px;
        right: 10px;
        width: auto;
    }

    #location-controls,
    #map-drawing-controls,
    #edit-submode-controls,
    #edit-mode-button,
    #draw-road-button,
    #draw-area-button,
    #road-options {
        width: 100%;
    }

    #coordinates {
        top: 62px;
        left: 10px;
        right: auto;
        bottom: auto;
    }
}

.object-history-fields select,
.object-history-fields input {
    box-sizing: border-box;
}

@media (max-width: 700px) {
    .object-history-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .object-history-actions {
        width: 100%;
    }

    .object-history-actions button {
        flex: 1;
    }
}

/* ==========================================================
   КАРТОЧКА БИОМА / АДАПТИВНЫЕ КНОПКИ
   ========================================================== */
#area-card .card-window {
    box-sizing: border-box;
    max-height: min(88vh, 780px);
    max-height: min(88dvh, 780px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: clamp(14px, 4vw, 26px);
}
#area-card .modal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-top: 14px;
}
#area-card .modal-actions button {
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
    padding: 10px 9px;
    border-radius: 7px;
    cursor: pointer;
}
#area-card #card-delete-area {
    grid-column: 1 / -1;
}
#area-card .modal-actions .hidden { display: none !important; }
#area-form .form-window {
    max-height: calc(100dvh - 24px);
    padding: clamp(14px, 4vw, 24px);
}
#area-form .form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
#area-form .form-actions button {
    min-width: 0;
    flex: 1 1 120px;
    white-space: normal;
}
@media (max-width: 480px), (max-height: 580px) {
    #area-card .card-window { max-width: calc(100vw - 20px); }
    #area-card .modal-actions { grid-template-columns: minmax(0, 1fr); }
    #area-card #card-delete-area { grid-column: auto; }
}

/* Диагностика биомов — компактная раскрывающаяся панель справа. */
.biome-audit-panel { box-sizing: border-box; width: 100%; min-width: 0; margin-top: 10px; padding: 0 8px; border: 1px solid #d5dfd7; border-radius: 7px; background: #fbfdfb; }
.biome-audit-panel > summary { cursor: pointer; font-size: 12px; font-weight: 600; line-height: 1.3; padding: 9px 1px; color: #34533c; }
.biome-audit-body { min-width: 0; padding: 3px 0 10px; }
.biome-audit-explainer, .biome-audit-disclaimer {
    font-size: 12px; line-height: 1.45; color: #525c56; margin: 2px 0 10px;
}
.biome-audit-disclaimer { margin-top: 9px; margin-bottom: 0; }
.biome-audit-buttons { display: flex; gap: 6px; }
.biome-audit-buttons button {
    box-sizing: border-box; flex: 1 1 0; min-width: 0;
    padding: 7px 6px; border: 1px solid #8b9f8e;
    border-radius: 6px; background: #fff; cursor: pointer;
    font-size: 12px;
}
.biome-audit-buttons button:disabled { cursor: default; opacity: .5; }
.biome-audit-status {
    margin: 9px 0; color: #284939; font-size: 12px;
    line-height: 1.5; overflow-wrap: anywhere;
}
.biome-audit-results { max-height: 255px; overflow-y: auto; overflow-x: hidden; }
.biome-audit-result {
    display: block; box-sizing: border-box; width: 100%;
    padding: 7px 8px; margin: 5px 0; border-radius: 6px;
    border: 1px solid #d5dcd5; background: #f9fbf9;
    text-align: left; white-space: normal; overflow-wrap: anywhere;
    font-size: 12px; line-height: 1.4; cursor: pointer;
}
.biome-audit-result:hover { background: #ecf4eb; }
.biome-audit-result .biome-audit-kind { display: block; font-weight: 700; margin-bottom: 2px; }
.biome-audit-result .biome-audit-name { display: block; }
.biome-audit-result.issue-error { border-left: 3px solid #c84a49; }
.biome-audit-result.issue-warning { border-left: 3px solid #c6953f; }
.biome-audit-result.issue-gap { border-left: 3px solid #488bb5; }

/* Единый редактор геометрии биомов (не меняет стили остальных окон) */
.biome-layer-editor-tip { font-size: 11px; line-height: 1.45; opacity: .85; margin: 6px 0; overflow-wrap: anywhere; }
#biome-layer-editor-controls { border: 1px solid #c9d4cb; background: rgba(255,255,255,.96); border-radius: 9px; padding: 10px; margin-top: 7px; box-sizing: border-box; max-width: 100%; color: #343d35; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.biome-layer-editor-heading { font-weight: 700; margin-bottom: 7px; color: #303d34; }
.biome-layer-editor-hint { overflow-wrap: anywhere; line-height: 1.4; font-size: 13px; color: #303d34; }
.biome-layer-editor-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; margin-top: 9px; }
.biome-layer-editor-actions button { min-width: 0; white-space: normal; padding: 7px 5px; background: #f9faf9; border: 1px solid #c3cdc4; color: #303d34; border-radius: 6px; font-size: 12px; }
#biome-layer-editor-save { grid-column: auto; background: #eaf3e9; border-color: #a7bba9; font-weight: 600; }
.biome-global-vertex { width: 12px !important; height: 12px !important; border-radius: 50%; box-sizing: border-box; background: #ffffff; border: 2px solid #188c53; box-shadow: 0 0 0 2px rgba(255,255,255,.65),0 1px 5px rgba(0,0,0,.4); cursor: none !important; transition: background 90ms, transform 90ms; }
.biome-global-vertex.shared { background: #35c37c; border-color: #125c39; }
.biome-global-vertex:hover { background: #fff7a8; transform: scale(1.2); }
body.biome-global-editing #timeline-controls, body.biome-global-editing #location-controls { pointer-events: none; opacity: .6; }
body.biome-global-editing .leaflet-marker-draggable, body.biome-global-editing .leaflet-interactive { cursor: none !important; }

/* Выделенная вершина единого редактора */
.biome-global-vertex.selected {
    background: #ffe187; border-color: #b16a12;
    box-shadow: 0 0 0 4px rgba(250,180,58,.35), 0 1px 6px rgba(0,0,0,.5);
}
#biome-layer-editor-delete-vertex:not(:disabled) { background: #fff3e7; color: #814224; }

/* ==========================================================
   ЕДИНЫЙ РЕДАКТОР ОБЛАСТЕЙ — РАЗМЕТКА И СТИЛЬ ПАНЕЛЕЙ
   ========================================================== */
#edit-area-controls .area-create-kind {
    border: 1px solid #d0d4d0;
    border-radius: 7px;
    background: rgba(255,255,255,.95);
    padding: 9px;
    margin-bottom: 7px;
}
#edit-area-controls #draw-area-button {
    border-radius: 7px;
    text-align: center;
    padding: 9px;
    background: rgba(255,255,255,.96);
    color: #303d34;
}
/* Инструменты S/M находятся в общем редакторе; отдельных блоков больше нет. */
.biome-layer-editor-shortcuts {
    margin-top: 7px; padding: 7px; border-radius: 6px;
    border: 1px solid #d6dfd6; background: #f5f8f5;
    font-size: 11px; line-height: 1.6; color: #354438;
}
.biome-layer-editor-shortcuts kbd {
    display: inline-block; padding: 0px 4px; border-radius: 3px;
    border: 1px solid #c5d3c6; background: white;
    font-family: inherit; font-weight: 700;
}

/* Создание биомов: компактная подсказка и предупреждение о пересечениях. */
.area-draw-feedback {
    box-sizing: border-box;
    width: 100%;
    padding: 8px 10px;
    margin: 6px 0;
    border: 1px solid #A5CDB0;
    border-radius: 5px;
    background: #F2F9F3;
    color: #305A3E;
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.area-draw-feedback.is-error {
    border-color: #E0A0A0;
    background: #FFF0F0;
    color: #A02B2B;
}

/* Резервные копии и защита данных карты */
.data-backup-panel > summary { cursor: pointer; font-weight: 600; }
.data-backup-content { display: grid; gap: 8px; padding-top: 10px; }
.data-backup-content p { font-size: 12px; line-height: 1.45; margin: 0; color: #555; }
.data-backup-content button { padding: 8px; background: #fff; border: 1px solid #b7b7b7; border-radius: 5px; }
#storage-warning { position: fixed; top: 50px; left: 10px; z-index: 1600;
    box-sizing: border-box; width: min(440px, calc(100vw - 30px)); padding: 12px;
    background: #fff2db; border: 2px solid #c07d17; border-radius: 6px;
    color: #6b3b08; font: 13px/1.5 Arial, sans-serif; box-shadow: 0 3px 12px #0002; }

/* ==========================================================
   КАТАЛОГ БИОМОВ И ДВА НЕЗАВИСИМЫХ ИЗОБРАЖЕНИЯ ОБЛАСТИ
   ========================================================== */
.biome-catalog-panel { padding: 0; }
.biome-catalog-panel > summary { padding: 11px 12px; cursor: pointer; font-size: 13px; font-weight: 700; }
.biome-catalog-panel[open] > summary { border-bottom: 1px solid #e5e5e5; }
.biome-catalog-content { display: grid; gap: 8px; padding: 10px 12px 12px; }
.biome-catalog-hint { color: #6b7278; font-size: 11px; line-height: 1.45; margin: 0; }
.biome-catalog-list { max-height: 310px; overflow-y: auto; display: grid; gap: 5px; }
.biome-catalog-empty { font-size: 12px; color: #7b8288; margin: 4px 0 7px; }
.biome-catalog-entry { display: flex; align-items: center; gap: 9px; text-align: left; padding: 5px; background: white; border: 1px solid #d7dcda; border-radius: 6px; min-width: 0; }
.biome-catalog-entry:hover { background: #f3f8f5; }
.biome-catalog-entry img, .biome-catalog-placeholder { height: 42px; width: 58px; flex-shrink: 0; object-fit: cover; border-radius: 4px; background: #eaf0e9; }
.biome-catalog-placeholder { display: grid; place-items: center; color: #84978a; font-size: 23px; }
.biome-catalog-entry-name { display: block; min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: 12px; font-weight: 600; }
.biome-catalog-entry-name small { display: block; font-size: 10px; margin-top: 3px; font-weight: 400; color: #7d8282; }
#biome-catalog-add { width: 100%; border: 1px solid #adbdb3; background: #f7faf8; padding: 8px; border-radius: 6px; font-size: 12px; }
#biome-catalog-form { z-index: 3500; }
#area-form .biome-catalog-inline-add { margin-top: 7px; padding: 7px 9px; border: 1px solid #adbdb3; background: #f8faf8; border-radius: 5px; width: 100%; font-size: 12px; }
.area-image-editor { display: grid; gap: 7px; margin: 4px 0 15px; }
.area-image-editor-title { font-size: 13px; font-weight: 600; }
.image-editor-actions { display: flex; gap: 7px; }
.image-editor-actions button { border: 1px solid #a9acaa; background: white; border-radius: 4px; padding: 6px 9px; font-size: 12px; }
.image-editor-actions button:disabled { opacity: .4; }
.area-image-editor input[type="text"] { width: 100%; box-sizing: border-box; padding: 8px; font-size: 13px; }
.image-editor-preview { padding: 6px; background: #f3f4f3; border-radius: 5px; border: 1px solid #dee0de; }
.image-editor-preview img { width: 100%; max-height: 160px; object-fit: contain; display: block; }
.biome-catalog-modal-actions { flex-wrap: wrap; }
#biome-catalog-delete { margin-right: auto; color: #923c36; }
.area-card-illustration { margin: 0 0 15px; text-align: center; }
.area-card-illustration img { display: block; max-height: 260px; width: 100%; object-fit: contain; }
.area-biome-reference { margin: 0 0 15px; border: 1px solid #d6dad5; background: #f5f8f5; padding: 6px; border-radius: 6px; }
.area-biome-reference-heading { color: #56635a; font-size: 11px; margin-bottom: 5px; }
.area-biome-reference img { display: block; width: 100%; height: 95px; object-fit: cover; border-radius: 4px; }

/* ==========================================================
   ПОИСК: БЫСТРЫЕ ПЕРЕХОДЫ К ОБЪЕКТАМ
   ========================================================== */

.quick-search-results {
    box-sizing: border-box;
    width: 100%;
    margin: -1px 0 9px;
    border: 1px solid #d5d8dc;
    border-radius: 5px;
    background: #fbfcfd;
    overflow: hidden;
}
.quick-search-summary {
    padding: 7px 9px;
    color: #56616a;
    font-size: 11px;
    line-height: 1.4;
    border-bottom: 1px solid #e5e7e9;
}
.quick-search-list { max-height: min(37vh, 260px); overflow-y: auto; }
.quick-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 32px;
    border-bottom: 1px solid #e9ebed;
}
.quick-search-row:last-child { border-bottom: none; }
.quick-search-goto,
.quick-search-edit {
    box-sizing: border-box;
    min-width: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #313c46;
}
.quick-search-goto {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 8px;
    text-align: left;
}
.quick-search-goto:hover:not(:disabled),
.quick-search-edit:hover:not(:disabled),
.quick-search-goto:focus-visible,
.quick-search-edit:focus-visible { background: #eaf1f6; }
.quick-search-name {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.quick-search-kind {
    font-size: 10px;
    color: #78818a;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.quick-search-edit {
    border-left: 1px solid #e2e5e8;
    font-size: 18px;
    font-weight: 700;
}
.quick-search-row button:disabled { opacity: 0.45; cursor: default; }
.quick-search-hint {
    padding: 6px 9px;
    border-top: 1px solid #e5e7e9;
    color: #79818a;
    font-size: 10px;
    line-height: 1.4;
}

/* Кнопка удаления только для существующих объектов в форме редактирования. */
.modal-actions .object-form-delete,
.form-actions .object-form-delete {
    margin-right: auto;
    color: #a13f3f;
    border-color: #d5a5a5;
    background: #fff9f9;
}
.modal-actions .object-form-delete:hover,
.form-actions .object-form-delete:hover { background: #ffeded; }
