:root {
    --map-bottom-bar-height: 64px;
    --map-profile-height: 0px;
    --map-preview-width: clamp(140px, 20vw, 230px);
}

body.profile-open {
    --map-profile-height: 100px;
}

#map,
body.profile-open #map {
    bottom: var(--map-profile-height) !important;
}

:is(#map-bottom-bar, #map-info-bar) {
    position: absolute;
    left: 0;
    right: var(--map-right, 25%);
    bottom: calc(var(--map-profile-height) + 8px);
    min-height: 64px;
    box-sizing: border-box;
    padding: 10px 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px 10px;
    background: transparent;
    border-top: none;
    z-index: 1006;
    pointer-events: none;
    transition: right 0.3s ease, bottom 0.3s ease;
}

:is(#map-bottom-bar, #map-info-bar) .map-bottom-controls {
    pointer-events: auto;
    display: flex;
    flex: 0 1 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 14px;
    min-width: 0;
    max-width: 100%;
    padding: 5px 14px;
    box-sizing: border-box;
    border: 1px solid #eeeeee;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 3px 12px rgba(24, 23, 19, 0.09);
}

:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay,
:is(#map-bottom-bar, #map-info-bar) #map-tools-row {
    position: relative;
    top: auto !important;
    bottom: auto;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    width: auto !important;
    max-width: 100% !important;
    margin: 0;
    transition: background 0.2s;
}

:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay {
    flex: 0 1 auto;
    min-width: 0;
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    padding: 4px 0;
    gap: 8px;
    box-sizing: border-box;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    justify-content: flex-start !important;
    overflow: hidden;
}

:is(#map-bottom-bar, #map-info-bar) .stats-horizontal-container {
    flex: 0 1 auto;
    min-width: 0;
    max-height: 100%;
    gap: 8px;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
}

:is(#map-bottom-bar, #map-info-bar) .stats-horizontal-container::-webkit-scrollbar {
    display: none;
}

:is(#map-bottom-bar, #map-info-bar) .stat-item {
    flex-shrink: 0;
    align-items: baseline;
    gap: 4px;
}

:is(#map-bottom-bar, #map-info-bar) .stat-val-info {
    line-height: 16px;
}

:is(#map-bottom-bar, #map-info-bar) .stat-label-info {
    display: none !important;
}

:is(#map-bottom-bar, #map-info-bar) .stats-toggle-btn {
    flex: 0 0 20px;
    position: static;
    width: 20px;
    height: 24px;
    box-sizing: border-box;
    background: transparent;
    padding: 0;
    margin: 0;
}

:is(#map-bottom-bar, #map-info-bar) #map-tools-row {
    flex: 0 1 auto;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 8px;
    margin-left: 0;
}

:is(#map-bottom-bar, #map-info-bar) #routing-mode-overlay,
:is(#map-bottom-bar, #map-info-bar) #map-layer-overlay {
    position: relative;
    height: 38px;
    border: 1px solid transparent;
    border-radius: 18px;
    box-shadow: none;
    background: #ffffff;
}

:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay:hover {
    background: #ffffff;
}

:is(#map-bottom-bar, #map-info-bar) .stats-toggle-btn:hover {
    color: #116e43;
}

:is(#map-bottom-bar, #map-info-bar) #routing-mode-overlay:hover,
:is(#map-bottom-bar, #map-info-bar) #map-layer-overlay:hover {
    background: transparent;
    border-color: transparent;
    color: #116e43;
}

:is(#map-bottom-bar, #map-info-bar) #routing-mode-overlay.open {
    border-radius: 0 0 18px 18px;
}

:is(#map-bottom-bar, #map-info-bar) .mode-dropdown {
    top: auto;
    bottom: 100%;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}

:is(#map-bottom-bar, #map-info-bar) #routing-mode-overlay.open .dropdown-arrow {
    transform: rotate(-90deg);
}

body #elevation-preview-overlay,
body.sidebar-closed #elevation-preview-overlay {
    position: fixed;
    top: auto;
    bottom: calc(var(--map-bottom-bar-height, 64px) + var(--map-profile-height, 0px) + 8px);
    left: auto;
    right: calc(var(--map-right) + 20px);
    display: flex;
    align-items: center;
    width: var(--map-preview-width);
    height: 72px;
    box-sizing: border-box;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    transition: right 0.3s ease, bottom 0.3s ease;
}

body #elevation-preview-overlay:hover {
    background: transparent;
}

body:not(.profile-open) #topbar .route-title-capsule {
    max-width: calc(100% - var(--map-right) - var(--map-preview-width) - 60px);
}

body.profile-open #elevation-preview-overlay {
    display: none !important;
}

body .preview-chart-container {
    flex: 1 1 auto;
    min-width: 0;
    height: 72px;
    overflow: hidden;
}

body .elevation-preview-chart {
    width: 100%;
    height: 72px;
    display: block;
}

body .elevation-preview-chart line,
body .elevation-preview-chart polyline {
    vector-effect: non-scaling-stroke;
}

body .preview-expand-btn {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 20px;
    width: 20px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #777777;
    cursor: pointer;
    pointer-events: auto;
}

body .preview-expand-btn:hover {
    color: #116e43;
}


#elevation-profile-overlay {
    bottom: 0;
}

#btn-feedback,
body.profile-open #btn-feedback {
    bottom: calc(var(--map-bottom-bar-height) + var(--map-profile-height) + 10px);
}

@media (max-width: 768px) {
    :is(#map-bottom-bar, #map-info-bar) {
        gap: 8px 12px;
        padding: 10px 12px;
    }

    :is(#map-bottom-bar, #map-info-bar) #map-tools-row {
        justify-content: center !important;
        margin-left: 0;
    }

    #mobile-banner {
        bottom: calc(var(--map-bottom-bar-height) + 20px);
    }
}

#map .leaflet-control-attribution.leaflet-control {
    margin: 0 2px 2px 0 !important;
}

:is(#map-bottom-bar, #map-info-bar) .stats-toggle-btn,
body .preview-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 20px;
    width: 20px;
    height: 24px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: #777777;
    line-height: 1;
}

:is(#map-bottom-bar, #map-info-bar) .stats-toggle-btn svg,
body .preview-expand-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

:is(#map-bottom-bar, #map-info-bar) .stats-toggle-btn:hover,
body .preview-expand-btn:hover {
    color: #116e43;
}

:is(#map-bottom-bar, #map-info-bar) #map-layer-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    padding: 0;
    box-sizing: border-box;
    cursor: pointer;
}

:is(#map-bottom-bar, #map-info-bar) .btn-topbar-ghost {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 18px;
    background: #ffffff;
    font-size: 12px;
    white-space: nowrap;
}

:is(#map-bottom-bar, #map-info-bar) .btn-topbar-ghost:hover {
    background: transparent;
    border-color: transparent;
    color: #116e43;
}

:is(#map-bottom-bar, #map-info-bar) #map-tools-row {
    padding-left: 0;
    background: transparent;
}

:is(#map-bottom-bar, #map-info-bar) button:focus-visible,
#sidebar-create-actions button:focus-visible {
    outline: 2px solid #116e43;
    outline-offset: 2px;
}

:is(#map-bottom-bar, #map-info-bar) .btn-topbar-ghost .icon-right {
    margin: 0;
}

:is(#map-bottom-bar, #map-info-bar) .stats-toggle-btn,
body .preview-expand-btn {
    display: none;
}

:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay,
body #elevation-preview-overlay {
    cursor: pointer;
}

#publish-badge-topbar:focus-visible,
:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay:focus-visible,
body #elevation-preview-overlay:focus-visible {
    outline: 2px solid #116e43;
    outline-offset: 2px;
}

#elevation-preview-overlay .grid-line {
    display: none;
}

#elevation-preview-overlay .chart-line {
    stroke: #78a58b;
    stroke-width: 1.5px !important;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: none !important;
}

#elevation-preview-overlay .chart-area {
    fill: rgba(126, 190, 151, 0.12);
}

body #elevation-preview-overlay {
    isolation: isolate;
}

#topbar .route-title-capsule::before,
#elevation-preview-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.25);
}

#elevation-preview-overlay::before {
    inset: -6px -8px;
}

:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay {
    cursor: pointer;
}

:is(#map-bottom-bar, #map-info-bar) #map-tools-row::before {
    content: "";
    flex: 0 0 1px;
    width: 1px;
    height: 20px;
    align-self: center;
    margin-right: 6px;
    background: #d4d8d5;
}

:is(#map-bottom-bar, #map-info-bar) .stat-metric-label {
    color: #303532;
    line-height: 16px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

#map .leaflet-control-attribution.leaflet-control {
    padding: 0 2px;
    font-size: 9px;
    font-weight: 600;
    line-height: 10px;
    background: rgba(255, 255, 255, 0.62) !important;
    border-radius: 9999px;
    box-shadow: none;
}

/* Bulles indépendantes de même hauteur, centrées sur chaque ligne. */
:is(#map-bottom-bar, #map-info-bar) {
    --toolbar-bubble-height: 40px;
}

:is(#map-bottom-bar, #map-info-bar) .map-bottom-controls {
    width: 100%;
    gap: 8px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
}

:is(#map-bottom-bar, #map-info-bar) #map-tools-row {
    display: contents;
}

:is(#map-bottom-bar, #map-info-bar) #map-tools-row::before,
:is(#map-bottom-bar, #map-info-bar) .route-title-capsule::before,
:is(#map-bottom-bar, #map-info-bar) #elevation-preview-overlay::before {
    content: none;
}

:is(#map-bottom-bar, #map-info-bar) :is(.route-title-capsule, #map-stats-overlay, #routing-mode-overlay, #map-layer-overlay, .btn-topbar-ghost, #elevation-preview-overlay) {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--toolbar-bubble-height);
    min-height: var(--toolbar-bubble-height);
    max-height: var(--toolbar-bubble-height);
    margin: 0;
    box-sizing: border-box;
    border: 1px solid #eeeeee;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 3px 12px rgba(24, 23, 19, 0.09);
    pointer-events: auto;
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule {
    flex: 0 1 auto;
    width: max-content;
    max-width: min(260px, 100%);
    min-width: 0;
    padding: 0 12px;
    gap: 8px;
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule .publish-badge {
    flex-shrink: 0;
    margin: 0;
    padding: 3px 9px;
    border-radius: 9999px;
    font-size: 11px;
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule .title-row {
    display: flex;
    align-items: center;
    min-width: 0;
    cursor: pointer;
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule .current-project-title {
    min-width: 0;
    margin: 0;
    color: #181713;
    font-size: 15px;
    font-weight: 600;
    line-height: 22px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: none;
    -webkit-text-stroke: 0;
}

:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay {
    flex: 0 0 auto;
    padding: 0 12px;
}

:is(#map-bottom-bar, #map-info-bar) #routing-mode-overlay {
    flex: 0 0 auto;
    padding: 0 12px;
}

:is(#map-bottom-bar, #map-info-bar) :is(#map-layer-overlay, .btn-topbar-ghost) {
    flex: 0 0 48px;
    width: 48px;
    padding: 0;
}

:is(#map-bottom-bar, #map-info-bar) :is(#routing-mode-overlay, #map-layer-overlay, .btn-topbar-ghost):hover {
    background: #f7f8f6;
    border-color: #eeeeee;
}

:is(#map-bottom-bar, #map-info-bar) #routing-mode-overlay.open {
    border-radius: 0 0 20px 20px;
}

:is(#map-bottom-bar, #map-info-bar) #elevation-preview-overlay {
    flex: 0 0 clamp(84px, 9.1vw, 126px);
    width: clamp(84px, 9.1vw, 126px);
    min-width: 0;
    padding: 0;
    overflow: hidden;
    transition: none;
}

:is(#map-bottom-bar, #map-info-bar) .preview-chart-container,
:is(#map-bottom-bar, #map-info-bar) .elevation-preview-chart {
    height: 100%;
    min-height: 0;
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule:hover {
    background: #f7f8f6;
}

:is(#map-bottom-bar, #map-info-bar) {
    container-type: inline-size;
}

@container (max-width: 850px) {
    :is(#map-bottom-bar, #map-info-bar) .map-bottom-controls {
        display: grid;
        grid-template-columns: repeat(12, minmax(0, 1fr));
        width: min(100%, 720px);
    }

    :is(#map-bottom-bar, #map-info-bar) .route-title-capsule,
    :is(#map-bottom-bar, #map-info-bar) #map-stats-overlay {
        grid-column: span 6;
        width: auto;
        max-width: 100%;
    }

    :is(#map-bottom-bar, #map-info-bar) #routing-mode-overlay,
    :is(#map-bottom-bar, #map-info-bar) #elevation-preview-overlay {
        grid-column: span 4;
        width: auto;
        min-width: 0;
    }

    :is(#map-bottom-bar, #map-info-bar) :is(#map-layer-overlay, .btn-topbar-ghost) {
        width: 100%;
        min-width: 0;
    }

    :is(#map-bottom-bar, #map-info-bar) #current-mode-text {
        margin: 0 6px !important;
        font-size: 12px;
    }
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule .title-row {
    flex: 1 1 auto;
    overflow: hidden;
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule .current-project-title {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    text-overflow: ellipsis;
}

:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay .stat-item {
    flex-direction: row;
    align-items: baseline;
    justify-content: center;
    gap: 0;
}

:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay .stat-val-info {
    line-height: 18px;
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule .current-project-title {
    font-size: 13px;
    line-height: 18px;
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule .publish-badge {
    font-size: 10px;
}

:is(#map-bottom-bar, #map-info-bar) #current-mode-text {
    font-size: 12px;
}

:is(#map-bottom-bar, #map-info-bar) .stat-val-info,
:is(#map-bottom-bar, #map-info-bar) .stat-metric-label {
    font-size: 13px;
    line-height: 18px;
}

:is(#map-bottom-bar, #map-info-bar) :is(#stat-ele, #stat-ele-neg) .unit {
    display: none;
}

:is(#map-bottom-bar, #map-info-bar) .preview-chart-container {
    width: 100%;
    padding: 0;
    overflow: hidden;
}

/* Le remplissage SVG s'arrête à 75 sur une hauteur de 80. */
:is(#map-bottom-bar, #map-info-bar) .elevation-preview-chart {
    display: block;
    width: 100%;
    height: 106.666667%;
    max-height: none;
}

@container (max-width: 850px) {
    :is(#map-bottom-bar, #map-info-bar) #elevation-preview-overlay {
        width: 70%;
        justify-self: center;
    }
}

#topbar .sidebar-title {
    -webkit-text-stroke: 0;
}

:is(#map-bottom-bar, #map-info-bar) .stat-metric-label,
:is(#map-bottom-bar, #map-info-bar) .stat-metric-sign {
    font-size: 10px;
    color: #777777;
    font-weight: 400;
}

:is(#map-bottom-bar, #map-info-bar) .route-title-capsule .current-project-title,
:is(#map-bottom-bar, #map-info-bar) #map-stats-overlay .stat-val-info {
    color: #181713;
}

@media (hover: hover) {
    :is(#map-bottom-bar, #map-info-bar) .route-title-capsule:hover .current-project-title,
    :is(#map-bottom-bar, #map-info-bar) #map-stats-overlay:hover .stat-val-info {
        color: #1b6e4b;
    }
}

#map .leaflet-control-attribution a {
    color: #303532;
    font-weight: 700;
}

/* Sidebar gauche et informations séparées des outils. */
body {
    --map-left: var(--sidebar-width);
    --map-right: 0%;
}

body.sidebar-closed {
    --map-left: 0%;
}

#sidebar,
body.sidebar-closed #sidebar {
    left: 0;
    right: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    container-type: inline-size;
    transition: left 0.3s ease;
}

body.sidebar-closed #sidebar {
    left: calc(0% - var(--sidebar-width));
}

#sidebar > #topbar {
    position: relative;
    inset: auto;
    flex: 0 0 auto;
    width: 100%;
    height: auto !important;
    padding: 20px 22px 14px !important;
    background: transparent;
    pointer-events: auto;
}

#sidebar #sidebar-footer {
    position: static;
    flex: 0 0 auto;
    height: auto;
    padding: 0 16px 8px;
    gap: 4px;
}

#sidebar #sidebar-create-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
}

#sidebar #sidebar-create-actions button {
    min-height: 38px;
    padding: 7px 12px;
    font-size: 12px;
}

#sidebar #btn-feedback {
    align-self: flex-start;
    padding-left: 0;
    text-align: left;
}

#sidebar #sidebar-filters {
    position: static;
    flex: 0 0 34px;
    margin: 0 16px 6px;
}

#sidebar #project-list-container {
    position: relative;
    inset: auto;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}

#sidebar > .mid-toggle-btn {
    left: auto;
    right: -28px;
    border: 2px solid #dadad6;
    border-left: none;
    border-radius: 0 8px 8px 0;
}

#sidebar > .mid-toggle-btn svg {
    transform: rotate(0deg);
}

body.sidebar-closed #sidebar > .mid-toggle-btn svg {
    transform: rotate(180deg);
}

#sidebar .project-item {
    grid-template-columns: clamp(52px, calc((100cqw - 60px) * 0.2295), 110px) minmax(0, 1fr);
    min-width: 0;
    column-gap: 12px;
    padding: 8px 10px;
}

#sidebar .project-thumb {
    aspect-ratio: 1;
    object-fit: cover;
}

#sidebar .project-info {
    gap: 3px;
}

#sidebar .project-name {
    font-size: 13px;
    line-height: 17px;
    max-height: 34px;
}

#map,
body.sidebar-closed #map {
    left: var(--map-left);
    right: 0;
    transition: left 0.3s ease, bottom 0.3s ease;
}

#map-info-bar {
    top: 16px;
    bottom: auto;
    left: calc(var(--map-left) + 20px);
    right: 20px;
    min-height: 0;
    padding: 0;
    gap: 8px;
    justify-content: flex-start;
    align-items: flex-start;
    container-type: normal;
    transition: left 0.3s ease;
}

#map-info-bar .route-title-capsule {
    max-width: min(260px, 100%);
}

#map-bottom-bar {
    left: var(--map-left);
    right: 0;
    transition: left 0.3s ease, bottom 0.3s ease;
}

#map-bottom-bar .map-bottom-controls {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: nowrap;
    width: max-content;
    gap: 4px;
    padding: 5px;
    border: 1px solid #e5e8e5;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 3px 12px rgba(24, 23, 19, 0.09);
}

#map-bottom-bar :is(#map-layer-overlay, .btn-topbar-ghost, #routing-mode-overlay) {
    border: 0;
    border-radius: 9px;
    box-shadow: none;
}

#map-bottom-bar :is(#map-layer-overlay, .btn-topbar-ghost) {
    flex: 0 0 40px;
    width: 40px;
    background: transparent;
}

#map-bottom-bar :is(#map-layer-overlay, .btn-topbar-ghost):hover {
    background: #f2f5f3;
}

#map-bottom-bar #routing-mode-overlay {
    min-width: 140px;
    background: #1b6e4b;
    color: #ffffff;
}

#map-bottom-bar #routing-mode-overlay:hover {
    background: #165c3f;
    color: #ffffff;
}

#map-bottom-bar #routing-mode-overlay.open {
    border-radius: 0 0 9px 9px;
}

#map-bottom-bar .mode-dropdown {
    color: #303532;
}

#elevation-profile-overlay,
body.sidebar-closed #elevation-profile-overlay {
    left: var(--map-left);
    right: 0;
    width: auto;
    transition: left 0.3s ease, transform 0.3s ease;
}

#map-empty-state,
body.sidebar-closed #map-empty-state {
    left: calc(var(--map-left) + 20px);
    right: 20px;
    top: 116px;
    width: auto;
}

@media (max-width: 767px) {
    body,
    body.sidebar-open,
    body.sidebar-closed {
        --map-left: 0%;
        --map-right: 0%;
    }

    #sidebar,
    body.sidebar-closed #sidebar {
        left: calc(0% - var(--sidebar-width));
        right: auto;
    }

    body.sidebar-open #sidebar {
        left: 0;
        right: auto;
    }

    body:not(.sidebar-open) #sidebar > .mid-toggle-btn svg {
        transform: rotate(180deg);
    }

    body.sidebar-open #sidebar > .mid-toggle-btn svg {
        transform: rotate(0deg);
    }

    #sidebar #sidebar-footer,
    #sidebar #btn-feedback,
    #sidebar #sidebar-create-actions button {
        display: flex !important;
    }

    #map-info-bar {
        left: 16px;
        right: 16px;
    }

    #map-bottom-bar {
        padding-left: 8px;
        padding-right: 8px;
    }

    #map-bottom-bar .map-bottom-controls {
        gap: 2px;
    }

    #map-bottom-bar #routing-mode-overlay {
        min-width: 0;
        padding: 0 8px;
    }

    #map-bottom-bar :is(#map-layer-overlay, .btn-topbar-ghost) {
        flex-basis: 36px;
        width: 36px;
    }
}

/* Barre compacte et capsule commune des informations. */
#map-bottom-bar {
    --toolbar-bubble-height: 34px;
}

#map-bottom-bar .map-bottom-controls {
    padding: 4px;
    border-radius: 9999px;
}

#map-bottom-bar :is(#map-layer-overlay, .btn-topbar-ghost, #routing-mode-overlay) {
    border-radius: 9999px;
}

#map-bottom-bar #routing-mode-overlay.open {
    border-radius: 0 0 17px 17px;
}

#map-info-bar .map-info-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    width: max-content;
    max-width: 100%;
    min-width: 0;
    gap: 0;
    overflow: hidden;
    border: 1px solid #e5e8e5;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 3px 12px rgba(24, 23, 19, 0.09);
    box-sizing: border-box;
    pointer-events: auto;
}

#map-info-bar .map-info-content > :is(.route-title-capsule, #map-stats-overlay, #elevation-preview-overlay) {
    margin: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

#map-info-bar .map-info-content > .route-title-capsule {
    padding-left: 14px;
}

#sidebar > #topbar {
    padding: 18px 20px 12px !important;
}

#sidebar #topbar .sidebar-title {
    font-size: 20px !important;
    line-height: 26px;
    letter-spacing: -0.4px;
}

#sidebar #sidebar-footer {
    padding: 0 20px 10px;
    gap: 7px;
    align-items: stretch;
}

#sidebar #sidebar-create-actions {
    flex-wrap: nowrap;
    gap: 8px;
}

#sidebar #sidebar-create-actions button {
    flex: 1 1 0;
    justify-content: center;
    min-width: 0;
    min-height: 34px;
    padding: 7px 8px;
    border-radius: 9px;
    font-size: 11px;
    line-height: 16px;
}

#sidebar #btn-feedback {
    align-self: flex-start;
    justify-content: flex-start;
    min-height: 24px;
    padding: 2px 0;
    gap: 6px;
    font-size: 10px;
    line-height: 15px;
    color: #858b87;
    text-align: left;
}

#sidebar #btn-feedback svg {
    flex-shrink: 0;
}

#sidebar #sidebar-filters {
    margin-left: 20px;
    margin-right: 20px;
}

#map-info-bar .map-info-content {
    column-gap: 8px;
}

#map-info-bar #map-stats-overlay .stats-horizontal-container {
    gap: 14px;
    align-items: center;
}

#map-info-bar #map-stats-overlay .stat-item {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

#map-info-bar #map-stats-overlay .stat-val-info {
    font-size: 13px;
    line-height: 17px;
}

#map-info-bar #map-stats-overlay .stat-metric-label {
    font-size: 10px;
    line-height: 12px;
    font-weight: 400;
    color: #777777;
}

#map-info-bar #map-stats-overlay :is(.unit, .stat-metric-sign) {
    display: none;
}

#map-info-bar .map-info-content {
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
    flex-wrap: nowrap;
}

#map-info-bar .map-info-content > .route-title-capsule {
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
    max-width: 260px;
    overflow: hidden;
}

#map-info-bar .route-title-capsule .title-row {
    min-width: 0;
    max-width: 100%;
}

#map-info-bar .route-title-capsule .current-project-title {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#sidebar #sidebar-create-actions button {
    min-height: 40px;
    padding-top: 10px;
    padding-bottom: 10px;
}

#sidebar .sidebar-help-footer {
    flex: 0 0 auto;
    padding: 8px 20px 12px;
    background: #ffffff;
}

@media (max-width: 767px) {
    #map-info-bar .map-info-content {
        flex-wrap: wrap;
    }
}

/* Palette et largeur fixe de la sidebar. */
:root,
body {
    --sidebar-width: 320px;
}

#sidebar {
    background: #F7F9FB;
}

#sidebar #sidebar-footer,
#sidebar .sidebar-help-footer {
    background: transparent;
}

#sidebar #topbar .sidebar-title {
    font-size: 24px !important;
    font-weight: 700;
    line-height: 26px;
}

#sidebar .sidebar-help-footer {
    margin-top: auto;
    padding: 4px 20px max(6px, env(safe-area-inset-bottom));
}

#map-info-bar .map-info-content {
    padding-right: 10px;
}

#map-bottom-bar #routing-mode-overlay {
    background: #15814C;
}

#map-bottom-bar #routing-mode-overlay:hover {
    background: #116B3F;
}

#map-bottom-bar #routing-mode-overlay .dropdown-arrow {
    color: #ffffff;
}

#sidebar #sidebar-create-actions .btn-importer-gpx {
    background: #E7F3EC;
    color: #15814C;
}

#sidebar #sidebar-create-actions .btn-importer-gpx:hover {
    background: #D8ECDF;
    color: #116B3F;
}

#map-bottom-bar .toolbar-separator {
    flex: 0 0 1px;
    width: 1px;
    height: 18px;
    margin: 0 3px;
    background: #e2e6e3;
    align-self: center;
}

#map-bottom-bar :is(#map-layer-overlay, #toolbar-share) {
    flex: 0 0 auto;
    width: auto;
    padding: 0 10px;
    gap: 7px;
}

#map-bottom-bar .toolbar-label,
#map-info-bar .preview-profile-label {
    font-family: 'Poppins', sans-serif;
    color: #181713;
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    white-space: nowrap;
}

#map-bottom-bar #toolbar-general {
    background: #f0f2f1;
}

#map-bottom-bar #toolbar-general:hover {
    background: #e4e8e5;
}

@media (max-width: 480px) {
    #map-bottom-bar :is(#map-layer-overlay, #toolbar-share) {
        padding: 0 6px;
        gap: 4px;
    }

    #map-bottom-bar .toolbar-label {
        font-size: 11px;
    }

    #map-bottom-bar .toolbar-separator {
        margin: 0 1px;
    }
}

/* Accès explicite au profil, sans modifier son graphique interactif. */
#map-info-bar #elevation-preview-overlay {
    flex: 0 0 clamp(150px, 14vw, 190px);
    width: clamp(150px, 14vw, 190px);
    gap: 10px;
}
#map-info-bar #elevation-preview-overlay .preview-chart-container {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
}
#map-info-bar .preview-profile-label {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    padding-right: 4px;
}
#map-info-bar #elevation-preview-overlay:hover .preview-profile-label { color: #15814C; }
#mobile-navigation,
#map-bottom-bar #toolbar-profile { display: none; }

/* Le message de démarrage garde une largeur de contenu, plafonnée. */
#map-empty-state,
body.sidebar-closed #map-empty-state {
    top: 100px !important;
    left: calc(var(--map-left) + 20px) !important;
    right: 20px !important;
    width: fit-content !important;
    max-width: min(520px, calc(100% - var(--map-left) - 40px));
    box-sizing: border-box;
    padding: 9px 14px;
    font-size: 12px;
    line-height: 18px;
}
#map-empty-state > svg { flex-shrink: 0; }

@media (max-width: 767px) {
    body { --mobile-navigation-height: calc(54px + env(safe-area-inset-bottom, 0px)); }
    body,
    body.sidebar-open,
    body.sidebar-closed { --sidebar-width: 100%; }
    #mobile-navigation {
        position: fixed;
        inset: auto 0 0;
        height: var(--mobile-navigation-height);
        box-sizing: border-box;
        padding: 0 12px env(safe-area-inset-bottom, 0px);
        display: flex;
        background: #ffffff;
        border-top: 1px solid #e5e8e5;
        z-index: 9998;
    }
    #mobile-navigation button {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        border: 0;
        background: transparent;
        color: #777d79;
        font: 500 12px 'Poppins', sans-serif;
        cursor: pointer;
    }
    #mobile-navigation button[aria-current="page"] { color: #15814C; }
    #sidebar,
    body.sidebar-closed #sidebar,
    body.sidebar-open #sidebar {
        bottom: var(--mobile-navigation-height);
        width: 100%;
    }
    #sidebar > .mid-toggle-btn { display: none !important; }
    #map,
    body.profile-open #map {
        bottom: calc(var(--mobile-navigation-height) + var(--map-profile-height)) !important;
    }
    #elevation-profile-overlay,
    body.sidebar-closed #elevation-profile-overlay {
        display: flex !important;
        bottom: var(--mobile-navigation-height);
        visibility: hidden;
        pointer-events: none;
    }
    body.profile-open #elevation-profile-overlay {
        visibility: visible;
        pointer-events: auto;
    }
    #map-bottom-bar {
        bottom: calc(var(--mobile-navigation-height) + var(--map-profile-height) + 8px);
        padding: 0 6px;
        min-height: 48px;
    }
    #map-bottom-bar .map-bottom-controls {
        flex-wrap: nowrap;
        gap: 2px;
        padding: 5px;
        pointer-events: auto;
    }
    #map-bottom-bar .toolbar-label { display: none; }
    #map-bottom-bar :is(#map-layer-overlay, #toolbar-share, #toolbar-general, #toolbar-profile) {
        display: flex;
        flex: 0 0 32px;
        width: 32px;
        padding: 0;
        gap: 0;
    }
    #map-bottom-bar #toolbar-profile[aria-expanded="true"] { color: #15814C; background: #e7f3ec; }
    #map-bottom-bar #routing-mode-overlay { flex: 0 1 auto; padding: 0 7px; }
    #map-bottom-bar #current-mode-text { font-size: 11px; margin: 0 4px !important; }
    #map-bottom-bar #routing-mode-overlay .dropdown-arrow { width: 12px; flex-shrink: 0; }
    #map-bottom-bar #current-mode-icon svg { width: 16px; }
    #map-bottom-bar .toolbar-separator { margin: 0 1px; }
    #map-info-bar {
        top: max(8px, env(safe-area-inset-top, 0px));
        left: 8px;
        right: 8px;
    }
    #map-info-bar .map-info-content {
        width: 100%;
        flex: 1 1 100%;
        flex-wrap: nowrap;
        column-gap: 4px;
        padding: 3px 8px;
        border-radius: 16px;
    }
    #map-info-bar .map-info-content > .route-title-capsule {
        flex: 1 1 0;
        max-width: none;
        padding: 0;
        gap: 5px;
    }
    #map-info-bar .route-title-capsule .publish-badge {
        font-size: 9px;
        padding: 3px 5px;
        white-space: nowrap;
    }
    #map-info-bar .route-title-capsule .current-project-title {
        font-size: 12px !important;
        line-height: 18px;
        font-weight: 600;
    }
    #map-info-bar #map-stats-overlay { flex: 0 0 auto; padding: 0 2px; }
    #map-info-bar #map-stats-overlay .stats-horizontal-container { gap: 8px; }
    #map-info-bar #map-stats-overlay .stat-val-info { font-size: 11px; }
    #map-info-bar #map-stats-overlay .stat-metric-label { font-size: 9px; }
    #map-info-bar #elevation-preview-overlay { display: none !important; }
    #map-empty-state,
    body.sidebar-closed #map-empty-state {
        top: calc(max(8px, env(safe-area-inset-top, 0px)) + 58px) !important;
        left: 16px !important;
        right: 16px !important;
        max-width: min(360px, calc(100% - 32px));
        font-size: 11px;
        line-height: 16px;
    }
}

/* Le titre se tronque avant que le statut puisse être masqué. */
#map-info-bar .map-info-content > .route-title-capsule {
    min-width: 86px;
}
#map-info-bar #publish-badge-topbar {
    display: inline-flex !important;
    align-items: center;
    flex: 0 0 auto;
    visibility: visible;
    opacity: 1;
    white-space: nowrap;
}

#map-bottom-bar #routing-mode-overlay .mode-dropdown {
    width: max-content;
    min-width: 100%;
    box-sizing: border-box;
}
#map-bottom-bar #routing-mode-overlay .mode-btn {
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    line-height: 16px;
    gap: 6px;
    padding: 9px 10px;
}
#map-info-bar #map-stats-overlay { padding-right: 16px; }

@media (max-width: 767px) {
    #map-bottom-bar #routing-mode-overlay .mode-btn { font-size: 11px; }
    #map-info-bar #map-stats-overlay { padding-right: 10px; }
}

/* Carte d'informations : statut, titre/données, profil. */
#map-info-bar .map-info-content {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(150px, 220px);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 16px;
    row-gap: 3px;
    flex: 0 1 auto;
    width: max-content;
    max-width: min(760px, 100%);
    min-height: 64px;
    padding: 8px 16px;
    border: 1px solid #edf0ee;
    border-radius: 20px;
    box-shadow: 0 3px 14px rgba(30, 45, 36, .07);
    overflow: hidden;
}
#map-info-bar .map-info-content > .route-title-capsule { display: contents !important; }
#map-info-bar #publish-badge-topbar {
    grid-column: 1;
    grid-row: 1 / 3;
    justify-content: center;
    margin: 0;
    padding: 8px 11px;
    border-radius: 9999px;
    background: #eef0f2;
    color: #303532;
    font-size: 12px;
    font-weight: 600;
    box-shadow: none;
}
#map-info-bar .route-title-capsule .title-row {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    width: 100%;
    min-width: 0;
    margin: 0;
}
#map-info-bar .route-title-capsule .current-project-title {
    font-family: 'Poppins', sans-serif;
    font-size: 16px;
    line-height: 23px;
    font-weight: 600;
}
#map-info-bar #map-stats-overlay {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    width: 100% !important;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 0 4px 0 0;
    overflow: hidden;
}
#map-info-bar #map-stats-overlay .stats-horizontal-container {
    gap: 0;
    flex-wrap: nowrap;
}
#map-info-bar #map-stats-overlay .stat-item {
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-start;
    gap: 3px;
    flex: 0 0 auto;
}
#map-info-bar #map-stats-overlay .stat-item + .stat-item::before {
    content: '·';
    margin: 0 5px;
    color: #7c837e;
}
#map-info-bar #map-stats-overlay :is(.stat-val-info, .stat-metric-label) {
    font-size: 12px;
    line-height: 18px;
    font-weight: 400;
    color: #555e59;
    white-space: nowrap;
}
#map-info-bar #map-stats-overlay .stat-val-info .unit {
    display: inline;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}
#map-info-bar #map-stats-overlay .stat-item:first-child .stat-metric-label,
#map-info-bar #map-stats-overlay .stat-metric-sign { display: none; }
#map-info-bar #elevation-preview-overlay {
    grid-column: 3;
    grid-row: 1 / 3;
    width: 100%;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    padding: 0 0 0 16px;
    gap: 12px;
    border-left: 1px solid #e5e8e6;
}
#map-info-bar #elevation-preview-overlay .preview-chart-container {
    height: 100%;
    border-radius: 0 0 9px 9px;
}
#map-info-bar #elevation-preview-overlay .chart-line {
    stroke: #286949;
    stroke-width: 1.5px;
    filter: none;
}
#map-info-bar #elevation-preview-overlay .chart-area { fill: rgba(40, 105, 73, .13); }
#map-info-bar .preview-profile-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: #f3f5f6;
    color: #303532;
}
#map-info-bar #elevation-preview-overlay:hover .preview-profile-label {
    background: #e7f3ec;
    color: #15814c;
}
body.profile-open #map-info-bar .map-info-content {
    grid-template-columns: auto minmax(0, 1fr);
    flex-basis: auto;
    width: max-content;
    max-width: min(520px, 100%);
}
@media (max-width: 767px) {
    #map-info-bar .map-info-content,
    body.profile-open #map-info-bar .map-info-content {
        grid-template-columns: auto minmax(0, 1fr);
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        min-height: 56px;
        padding: 6px 10px;
        column-gap: 10px;
        row-gap: 2px;
        border-radius: 16px;
    }
    #map-info-bar #publish-badge-topbar { font-size: 10px; padding: 7px 8px; }
    #map-info-bar .route-title-capsule .current-project-title {
        font-size: 14px !important;
        line-height: 20px;
    }
    #map-info-bar #map-stats-overlay { padding-right: 2px; }
    #map-info-bar #map-stats-overlay :is(.stat-val-info, .stat-metric-label) {
        font-size: 10px;
        line-height: 16px;
    }
    #map-info-bar #map-stats-overlay .stat-item + .stat-item::before { margin: 0 3px; }
    #map-info-bar #map-stats-overlay .stat-item { gap: 2px; }
    #map-empty-state,
    body.sidebar-closed #map-empty-state {
        top: calc(max(8px, env(safe-area-inset-top, 0px)) + 76px) !important;
    }
}
@media (min-width: 768px) and (max-width: 1100px) {
    #map-info-bar .map-info-content {
        grid-template-columns: auto minmax(0, 1fr) 110px;
        column-gap: 10px;
        padding: 8px 10px;
    }
    #map-info-bar #publish-badge-topbar { font-size: 10px; padding: 7px; }
    #map-info-bar #map-stats-overlay :is(.stat-val-info, .stat-metric-label) { font-size: 10px; }
    #map-info-bar #map-stats-overlay .stat-item + .stat-item::before { margin: 0 2px; }
    #map-info-bar #elevation-preview-overlay { padding-left: 10px; gap: 6px; }
    #map-info-bar .preview-profile-label { width: 28px; height: 28px; }
}

#map-info-bar .route-title-capsule .title-row,
#map-info-bar #map-stats-overlay {
    justify-self: stretch;
    margin-left: 0;
    padding-left: 0;
    text-align: left;
}
#map-info-bar #map-stats-overlay,
#map-info-bar #map-stats-overlay .stats-horizontal-container {
    justify-content: flex-start !important;
}
