.map-page {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 700px;
    --map-footer-reserve: 4.5rem;
    padding-bottom: var(--map-footer-reserve);
    box-sizing: border-box;
}

.map-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.map-toolbar-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.75rem;
}

.map-toolbar-main {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1 1 auto;
}

.map-toolbar-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.map-toolbar-about,
.map-tile-btn,
a.map-toolbar-chart {
    font-size: 0.8rem;
    padding: 0.2rem 0.55rem;
    line-height: 1.3;
}

a.map-toolbar-chart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    box-sizing: border-box;
}

a.map-toolbar-chart .fa-area-chart {
    line-height: 1.3;
    font-size: 1em;
}

button.map-toolbar-weather {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
    padding: 0.2rem 0.55rem;
    line-height: 1.3;
    border: inherit;
    vertical-align: middle;
}

a.map-toolbar-weather {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-decoration: none;
}

.map-toolbar-weather .map-toolbar-weather-temp {
    font-variant-numeric: tabular-nums;
}

.map-toolbar-weather .rf4-weather-water-level-arrow,
.location-page-actions .rf4-weather-water-level-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    line-height: 1;
    height: 1em;
    margin-left: 0.2rem;
    font-size: 1em;
    font-weight: 700;
    /* Unicode ↑↓↕ сидят ниже оптического центра рядом с цифрами */
    transform: translateY(-0.14em);
}

.map-toolbar-title-row {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.map-toolbar-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--fp-color);
    text-decoration: none;
    border-bottom: 1px dashed;
}

.map-location-check {
    width: auto;
    flex-shrink: 0;
    margin: 0;
    cursor: pointer;
}

.map-toolbar-title:hover {
    text-decoration: none;
    opacity: 0.85;
}

.map-tile-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
}

.map-tile-stat strong {
    font-weight: 700;
    color: var(--text-main);
}

.map-tile-stat-link {
    color: inherit;
    text-decoration: none;
}

.map-tile-stat-link strong {
    text-decoration: underline;
}

.map-tile-stat-link:hover strong {
    text-decoration: underline;
}

.map-tile-more {
    font-size: 0.85rem;
    color: var(--fp-color);
    text-decoration: none;
    border-bottom: 1px dashed;
}

.map-tile-more:hover {
    text-decoration: none;
    opacity: 0.85;
}

.map-page-stats {
    margin: 0 0 0.5rem;
}

.map-page-stats .posts-list-stats {
    margin: 0;
}

.map-coords {
    position: absolute;
    top: 0.4rem;
    right: 0.45rem;
    z-index: 1000;
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    line-height: 1.3;
    color: #fff;
    background: rgba(0, 0, 0, 0.72);
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
}

.leaflet-bar a.leaflet-control-ruler {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
}

.leaflet-touch .leaflet-bar a.leaflet-control-ruler {
    font-size: 15px;
}

.leaflet-bar a.leaflet-control-ruler--active,
.leaflet-bar a.leaflet-control-ruler--active:hover {
    background: #f0ad4e;
    color: #1a1a1a;
}

.leaflet-container.map-ruler-active .leaflet-interactive {
    pointer-events: none !important;
}

.leaflet-tooltip.map-ruler-label {
    background: rgba(0, 0, 0, 0.8);
    border: none;
    border-radius: 4px;
    color: #fff;
    box-shadow: none;
    font-size: 0.85rem;
    padding: 0.2rem 0.45rem;
    white-space: nowrap;
}

.leaflet-tooltip.map-ruler-label::before {
    border-top-color: rgba(0, 0, 0, 0.8);
}

.leaflet-tooltip.map-ruler-label--cursor {
    pointer-events: none;
}

.leaflet-tooltip.map-ruler-label--cursor::before {
    display: none;
}

.map-page--grid {
    min-height: auto;
}

.map-page--detail:not(.map-page--grid) {
    min-height: auto;
}

.map-page--detail .map-detail-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1.25rem;
    flex: 1 1 auto;
    min-width: 0;
}

.map-page--detail:not(.map-page--grid) .map-grid-item .map-container-wrap {
    flex: 0 0 auto;
    width: min(560px, 52vw);
    aspect-ratio: 1;
    height: auto;
    min-height: 0;
    max-height: none;
}

.map-legend {
    flex: 1 1 240px;
    min-width: 200px;
    max-width: 340px;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 0.9rem;
    line-height: 1.45;
}

.map-legend-title {
    margin: 0 0 0.65rem;
    font-size: 1rem;
    font-weight: 600;
}

.map-legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.map-legend-icon {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    line-height: 1;
}

.map-legend-icon--count,
.map-legend-icon--yellow {
    background: rgba(255, 255, 0, 0.95);
    color: #000;
}

.map-legend-icon--red {
    background: rgba(255, 0, 0, 0.9);
    color: #fff;
}

.map-legend-text {
    flex: 1 1 auto;
    min-width: 0;
}

.map-legend-hint {
    margin: 0.85rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    opacity: 0.9;
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.map-grid--single {
    grid-template-columns: 1fr;
    flex: 1;
    min-height: 0;
}

.map-page:not(.map-page--grid) .map-grid-item {
    flex: 1;
    min-height: 0;
}

.map-page:not(.map-page--grid) .map-grid-item .map-container-wrap {
    flex: 1;
    min-height: 0;
}

.map-grid-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.map-page--grid .map-container-wrap {
    flex: none;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    aspect-ratio: 1;
}

.map-empty-message {
    margin: 1rem 0;
    text-align: center;
    opacity: 0.75;
}

.map-grid-sort-bar {
    justify-content: flex-end;
}

.map-container-wrap {
    position: relative;
    flex: 1;
    min-height: 480px;
    height: calc(100vh - 220px - var(--map-footer-reserve, 4.5rem));
    max-height: calc(900px - var(--map-footer-reserve, 4.5rem));
    border-radius: 6px;
    overflow: hidden;
    background: #1a1a1a;
}

.map-container-wrap .map-container {
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: none;
    max-height: none;
    border-radius: 0;
}

.map-container {
    flex: 1;
    min-height: 480px;
    height: calc(100vh - 220px - var(--map-footer-reserve, 4.5rem));
    max-height: calc(900px - var(--map-footer-reserve, 4.5rem));
    border-radius: 6px;
    overflow: hidden;
    background: #1a1a1a;
}

.map-container.leaflet-container {
    cursor: crosshair;
    background: #1a1a1a;
    z-index: 0;
}
/* Пока карту не тапнули — один палец скроллит страницу (см. rf4MapBindPageFriendlyZoom) */
.map-container.leaflet-container.map-page-scroll,
.active-spot-map.leaflet-container.map-page-scroll,
.map-spot-preview-map.leaflet-container.map-page-scroll {
    cursor: grab;
}
.map-container.leaflet-container.map-interaction-on,
.active-spot-map.leaflet-container.map-interaction-on,
.map-spot-preview-map.leaflet-container.map-interaction-on {
    cursor: crosshair;
}

.map-marker-single,
.map-marker-cluster {
    background: transparent !important;
    border: none !important;
}

.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom {
    z-index: 900;
}

.map-zone-label {
    background: rgba(0, 0, 0, 0.75);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    padding: 3px 8px;
}

.map-modal {
    position: fixed;
    inset: 0;
    /* ниже .post-detail-panel (1250), выше .back-to-top (1200) */
    z-index: 1210;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.map-modal.is-open {
    display: flex;
    overflow: hidden;
}

.map-modal[hidden] {
    display: none !important;
}

.map-modal.is-open[hidden] {
    display: flex !important;
}

.map-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.map-modal-dialog {
    position: relative;
    z-index: 1;
    background: var(--bg-body);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    max-height: min(90vh, 820px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.dark-theme .map-modal-dialog {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.72);
}

.map-modal-close {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    z-index: 2;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
}

.map-modal-close:hover {
    opacity: 1;
    background: var(--bg-hover);
    border-radius: 4px;
}

/* Как .post-detail-panel-drawer: шапка вне потока скролла, body скроллится */
.map-posts-modal-dialog {
    width: min(1150px, 96vw);
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* явная высота как у drawer (top/bottom) — иначе flex-скролл не срабатывает */
    height: min(90vh, 820px);
    max-height: min(90vh, 820px);
}

.map-posts-modal .keepnet-value-coin .tooltip-data {
    left: 0;
    right: auto;
}

.map-posts-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-body);
    box-sizing: border-box;
}

.map-posts-modal-header .map-modal-close {
    position: static;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
}

.map-posts-modal-title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.map-posts-modal-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-sizing: border-box;
}

.map-posts-modal .js-map-posts-lead-info {
    padding: 0.5rem 1rem 0;
}

.map-posts-modal .js-map-posts-lead-info .rf4-lead-block {
    margin-bottom: 0;
}

.map-posts-modal .posts-list-stats {
    margin: 0;
    padding: 0.5rem 1rem 0.75rem;
}

.map-posts-modal .posts-list-stats--loading {
    min-height: 120px;
}

.map-posts-modal-posts {
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid var(--border-color);
}

.map-posts-modal-body {
    display: grid;
    grid-template-columns: repeat(2,  1fr);    
    gap: 10px;
}

/* ширина контента как .view-main / список постов */
.map-posts-modal-body .post-item {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.map-posts-modal-body .post-info,
.map-posts-modal-body .post-detail {
    max-width: 100%;
    box-sizing: border-box;
}

.map-posts-modal-empty {
    margin: 0;
    padding: 1rem;
    text-align: center;
    opacity: 0.75;
}

.map-posts-empty--hidden {
    display: none;
}

.map-tracker-modal .map-tracker-list-table {
    width: 100%;
    margin: 0;
    padding: 0;
}

.map-tracker-modal .map-tracker-list-table thead .header td {
    font-size: 13px;
}

.map-tracker-modal .map-tracker-list-table .list-gamer img {
    display: none;
}

.map-tracker-page-list {
    margin: 1rem 0 0;
}

.map-tracker-page-list-scroll {
    max-height: min(70vh, 720px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
}

.map-tracker-page-list-empty {
    margin: 0.75rem 0 0;
    text-align: center;
    opacity: 0.75;
}

.map-premium-modal-dialog {
    width: min(620px, 96vw);
    padding: 2rem 1.25rem 1.25rem;
}

.map-premium-modal-dialog .posts-premium-cta {
    margin: 0;
}

.map-premium-posts-link-wrap {
    margin: 14px 0 0;
}

.map-premium-posts-link {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    font-size: 16px;
    padding: 8px 12px;
}

.map-spot-preview-modal-dialog {
    width: min(720px, 96vw);
    padding: 0;
}

.map-spot-preview-title {
    margin: 0;
    padding: 1rem 2.5rem 0.5rem 1rem;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.map-spot-preview-map {
    height: min(70vh, 520px);
    min-height: 320px;
    background: #1a1a1a;
}

.map-spot-preview-map.leaflet-container {
    cursor: default;
}

.map-spot-preview-loading,
.map-spot-preview-error {
    margin: 0;
    padding: 2rem 1rem;
    text-align: center;
    opacity: 0.75;
}

.map-spot-picker-modal-dialog {
    width: min(920px, 96vw);
    max-height: min(92vh, 900px);
}

.map-spot-picker-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 2.5rem 0.5rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.map-spot-picker-coords {
    font-family: monospace;
    font-size: 0.95rem;
}

.map-spot-picker-catches-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.map-spot-picker-selected-row {
    padding: 0.35rem 1rem;
    font-size: 0.9rem;
}

.map-spot-picker-map {
    flex: 1 1 auto;
    min-height: 360px;
    height: 50vh;
}

.map-spot-picker-map.leaflet-container {
    z-index: 0;
}

.map-spot-picker-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.map-zone-pick-label {
    background: transparent;
    border: none;
}

.map-zone-pick-label-inner {
    display: inline-block;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.map-zone-pick-label-inner:hover {
    background: rgba(74, 144, 217, 0.95);
}

.map-marker-catch {
    cursor: pointer;
}

.map-catch-coords-tooltip {
    background: rgba(0, 0, 0, 0.8);
    border: none;
    color: #fff;
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    white-space: nowrap;
}

.map-catch-coords-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.8);
}

.map-spot-zone-editor-dialog {
    width: min(1100px, 98vw);
    max-height: min(94vh, 920px);
}

.map-spot-zone-editor-title {
    margin: 0;
    padding: 0.75rem 2.5rem 0.5rem 1rem;
    font-size: 1.15rem;
}

.map-spot-zone-editor-body {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.map-spot-zone-editor-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    width: 200px;
    flex: 0 0 200px;
    overflow-y: auto;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

.spot-zone-editor-list-item {
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.spot-zone-editor-list-item:hover,
.spot-zone-editor-list-item.is-active {
    background: rgba(74, 144, 217, 0.15);
}

.spot-zone-editor-list-item.is-new {
    font-weight: 600;
    color: #4a90d9;
}

.map-spot-zone-editor-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.map-spot-zone-editor-map {
    flex: 1 1 auto;
    min-height: 280px;
    height: 45vh;
}

.map-spot-zone-editor-map.leaflet-container {
    z-index: 0;
}

.map-spot-zone-editor-form {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 0.35rem 0.75rem;
    align-items: center;
}

.map-spot-zone-editor-form label {
    font-size: 0.85rem;
}

.map-spot-zone-editor-form input[type="text"],
.map-spot-zone-editor-form input[type="number"],
.map-spot-zone-editor-form textarea {
    width: 100%;
    box-sizing: border-box;
}

.map-spot-zone-editor-form textarea {
    grid-column: 2 / -1;
}

.map-spot-zone-active-label {
    grid-column: 1 / -1;
}

.map-spot-zone-editor-form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
    padding-top: 0.35rem;
}

@media (max-width: 720px) {
    .map-spot-zone-editor-body {
        flex-direction: column;
    }

    .map-spot-zone-editor-list {
        width: 100%;
        flex: 0 0 auto;
        max-height: 120px;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }
}

.spot-with-map {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    vertical-align: middle;
}

.js-spot-map-btn {
    border: none;
    background: transparent;
    padding: 0 0.1rem;
    cursor: pointer;
    opacity: 0.8;
    color: inherit;
    line-height: 1;
    font-size: 0.95em;
}

.js-spot-map-btn:hover {
    opacity: 1;
}

@media (max-width: 1024px) {
    .map-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .map-page--detail .map-detail-layout {
        flex-direction: column;
    }

    .map-page--detail:not(.map-page--grid) .map-grid-item .map-container-wrap {
        width: 100%;
        max-width: min(560px, 100%);
    }

    .map-legend {
        flex: 0 0 auto;
        width: auto;
        min-width: 0;
        max-width: min(100%, 340px);
        align-self: flex-start;
    }
}

@media (max-width: 480px) {
    .map-page {
        --map-footer-reserve: 0;
        padding-bottom: 0;
        min-height: 400px;
    }

    .map-grid {
        grid-template-columns: 1fr;
    }

    .map-page--grid .map-container-wrap {
        min-height: 0;
        height: auto;
        max-height: none;
    }

    .map-container-wrap {
        min-height: 360px;
        height: 480px;
        max-height: none;
    }

    .map-container {
        min-height: 360px;
        height: 480px;
        max-height: none;
    }

    .map-page--detail .map-detail-layout {
        gap: 0.85rem;
    }

    .map-page--detail:not(.map-page--grid) .map-grid-item .map-container-wrap,
    .map-page--detail:not(.map-page--grid) .map-grid-item .map-container {
        width: 100%;
        aspect-ratio: 1;
        min-height: 0;
        height: auto;
        max-height: none;
    }

    .map-page--detail .map-legend {
        width: auto;
        max-width: 100%;
    }

    .map-posts-modal.map-modal {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .map-posts-modal .map-modal-backdrop {
        display: none;
    }

    .map-posts-modal .map-posts-modal-dialog {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
        overflow: hidden;
    }

    .map-posts-modal-header {
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .map-posts-modal-posts {
        padding: 0.75rem 0.625rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    .map-posts-modal-body {
        display: block;
        gap: 0;
    }
    .map-posts-modal .map-posts-modal-body {
        padding: 0;
    }

    .map-posts-modal .map-posts-modal-body .post-info,
    .map-posts-modal .map-posts-modal-body .post-detail {
        flex: 1 1 100%;
        min-width: 0;
        width: auto;
        max-width: 100%;
    }

    .map-posts-modal .map-posts-modal-body .post-item .user {
        max-width: 100%;
    }
}
