:root {
    --bg: #dce0e5;
    --panel: rgba(255, 255, 255, 0.97);
    --line: rgba(228, 232, 241, 0.9);
    --text: #252730;
    --muted: #7b7f8d;
    --purple: #5e2cff;
    --purple-dark: #4d1df2;
    --shadow: 0 18px 42px rgba(15, 24, 40, 0.16);
    --overlay: rgba(24, 35, 46, 0.52);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
input,
textarea {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.map-screen {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    background: #dce0e5;
}

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


.top-controls {
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    z-index: 760;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    pointer-events: none;
}

.provider-switch,
.search-box,
.bottom-controls,
.status-toast,
.trace-modal,
.pick-sidecard {
    pointer-events: auto;
}

.provider-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}

.provider-switch[hidden] {
    display: none !important;
}

.provider-btn {
    border: 0;
    background: transparent;
    color: #707483;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.provider-btn.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--purple), #7b4dff);
}

.search-box {
    position: relative;
    margin-left: auto;
    width: min(360px, 100%);
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.search-box input,
.search-box button,
.badge-link,
.trace-button,
.side-cancel,
.submit-button {
    box-shadow: var(--shadow);
}

.search-box input {
    flex: 1;
    height: 38px;
    min-width: 0;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 0 14px;
    outline: none;
    color: #616570;
}

.search-box input::placeholder {
    color: #9a9eaa;
}

.search-box button {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    color: #5d6270;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex: 0 0 auto;
}

.search-results {
    position: absolute;
    top: 48px;
    left: 0;
    width: calc(100% - 46px);
    background: rgba(255, 255, 255, 0.99);
    border-radius: 24px;
    box-shadow: 0 20px 42px rgba(18, 28, 45, 0.18);
    padding: 10px;
    display: none;
    max-height: min(440px, calc(100vh - 120px));
    overflow: auto;
}

.search-results.is-visible {
    display: block;
}

.search-section + .search-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eceff5;
}

.search-section-title {
    padding: 4px 10px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #8b90a1;
}

.search-section-content {
    display: grid;
    gap: 6px;
}

.search-item {
    display: block;
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 18px;
    padding: 12px 12px 11px;
    cursor: pointer;
    text-align: left;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.search-item + .search-item {
    margin-top: 6px;
}

.search-item:hover {
    background: #f7f8fc;
    border-color: #eceff7;
    transform: translateY(-1px);
}

.search-meta {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.search-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.search-badge.note {
    color: #4d1df2;
    background: rgba(94, 44, 255, 0.1);
}

.search-badge.city {
    color: #156fa5;
    background: rgba(21, 111, 165, 0.1);
}

.search-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    color: #1f2430;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.search-subtitle,
.search-message,
.search-empty {
    color: #757b8b;
    font-size: 13px;
    line-height: 1.42;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.search-subtitle {
    margin-top: 4px;
}

.search-message {
    color: #525866;
    margin-top: 6px;
}

.search-empty {
    padding: 14px 12px 12px;
}

.bottom-controls {
    position: absolute;
    left: 18px;
    bottom: 18px;
    z-index: 760;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-link,
.trace-button {
    background: rgba(255, 255, 255, 0.96);
}

.badge-link {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.badge-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.trace-button {
    height: 42px;
    border: 0;
    border-radius: 12px;
    color: #171922;
    cursor: pointer;
    white-space: nowrap;
    padding: 0 16px;
}

.pick-overlay {
    position: absolute;
    inset: 0;
    z-index: 780;
    pointer-events: none;
}

.pick-dim {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: var(--overlay);
}

.pick-overlay[hidden] {
    display: none;
}

.pick-sidecard {
    position: absolute;
    left: 26px;
    top: 50%;
    z-index: 4;
    transform: translateY(-50%);
    width: min(330px, calc(100vw - 48px));
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.98);
    padding: 22px 22px 18px;
    box-shadow: 0 26px 60px rgba(18, 28, 45, 0.24);
}

.pick-kicker {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--purple);
    font-weight: 700;
    margin-bottom: 10px;
}

.pick-sidecard h2 {
    margin: 0 0 10px;
    font-size: 28px;
    line-height: 1.1;
}

.pick-sidecard p {
    margin: 0;
    color: #667085;
    line-height: 1.48;
}

.side-cancel {
    margin-top: 18px;
    border: 0;
    border-radius: 12px;
    height: 42px;
    background: #eef1f7;
    color: #232735;
    cursor: pointer;
    padding: 0 16px;
}


.pick-point-ui {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 5;
    width: 0;
    height: 0;
    pointer-events: auto;
}

.pick-point-ui[hidden] {
    display: none;
}

.pick-point-pin {
    position: absolute;
    left: 0;
    top: 0;
    width: 40px;
    height: 54px;
    transform: translate(-50%, -100%);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    filter: drop-shadow(0 10px 18px rgba(94, 44, 255, 0.35));
    pointer-events: none;
}

.pick-point-card {
    position: absolute;
    left: 0;
    top: 0;
    min-width: 280px;
    width: min(310px, calc(100vw - 42px));
    max-width: min(310px, calc(100vw - 42px));
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.98);
    padding: 16px;
    box-shadow: 0 22px 52px rgba(18, 28, 45, 0.24);
    pointer-events: auto;
}

.pick-point-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    color: #303544;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.pick-point-actions {
    display: flex;
    gap: 8px;
}

.pick-point-actions button {
    flex: 1;
    height: 38px;
    border-radius: 12px;
    border: 0;
    cursor: pointer;
    font-weight: 700;
}

.status-toast {
    position: absolute;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 14px);
    z-index: 820;
    background: rgba(24, 28, 40, 0.94);
    color: #fff;
    padding: 11px 16px;
    border-radius: 14px;
    opacity: 0;
    transition: .2s ease;
    pointer-events: none;
}

.status-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 860;
    display: grid;
    place-items: center;
    background: rgba(24, 35, 46, 0.52);
    padding: 20px;
}

.modal-overlay[hidden] {
    display: none;
}

.trace-modal {
    position: relative;
    z-index: 1;
    width: min(418px, calc(100vw - 28px));
    max-height: min(88vh, 720px);
    overflow: auto;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.99);
    padding: 18px;
    box-shadow: 0 26px 60px rgba(18, 28, 45, 0.26);
}

.trace-modal h2 {
    margin: 0 38px 16px 0;
    font-size: 22px;
    line-height: 1.15;
    color: #393b44;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: transparent;
    color: #6b6f7d;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

#traceForm {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#traceForm input[type="text"],
#traceForm input[type="email"],
#traceForm textarea {
    width: 100%;
    border: 0;
    background: #dedee1;
    border-radius: 12px;
    padding: 12px 14px;
    color: #3d4048;
    outline: none;
}

#traceForm textarea {
    min-height: 142px;
    resize: vertical;
}

.picked-place {
    min-height: 22px;
    padding: 4px 2px 2px;
    font-size: 13px;
    color: #666c79;
}

.consent-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    line-height: 1.4;
    color: #434551;
}

.consent-row input {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: var(--purple);
    flex: 0 0 auto;
}

.submit-button {
    margin-top: 4px;
    height: 46px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(90deg, var(--purple), #6b34ff);
}

.submit-button:disabled {
    opacity: .72;
    cursor: default;
}

.leaflet-top,
.leaflet-bottom {
    z-index: 640;
}

#map .leaflet-tile-pane {
    z-index: 200;
}

#map .leaflet-overlay-pane {
    z-index: 400;
}

#map .leaflet-shadow-pane {
    z-index: 500;
}

#map .leaflet-marker-pane {
    z-index: 620;
}

#map .leaflet-tooltip-pane {
    z-index: 660;
}

#map .leaflet-popup-pane {
    z-index: 700;
}

.leaflet-control-zoom {
    border: 0 !important;
    box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
    width: 42px !important;
    height: 42px !important;
    line-height: 42px !important;
    border: 0 !important;
    color: #232735 !important;
    font-size: 30px !important;
}

.leaflet-control-zoom a:first-child {
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
}

.leaflet-control-zoom a:last-child {
    border-bottom-left-radius: 12px !important;
    border-bottom-right-radius: 12px !important;
}

.leaflet-bottom.leaflet-right .leaflet-control {
    margin-right: 18px;
    margin-bottom: 18px;
}

.custom-popup .leaflet-popup-content-wrapper,
.temp-popup .leaflet-popup-content-wrapper {
    width: min(390px, calc(100vw - 48px));
    max-width: min(390px, calc(100vw - 48px)) !important;
    border-radius: 20px;
    padding: 0;
    box-shadow: 0 22px 52px rgba(18, 28, 45, 0.24);
    overflow: hidden;
}

.custom-popup .leaflet-popup-content,
.temp-popup .leaflet-popup-content {
    margin: 0;
    width: 100% !important;
}

.custom-popup.leaflet-popup,
.temp-popup.leaflet-popup {
    z-index: 700 !important;
}

.custom-popup .leaflet-popup-tip-container,
.temp-popup .leaflet-popup-tip-container,
.custom-popup .leaflet-popup-close-button,
.temp-popup .leaflet-popup-close-button {
    display: none;
}

.popup-card {
    position: relative;
    width: 100%;
    max-width: none;
    padding: 18px 18px 18px 16px;
    overflow: hidden;
}

.popup-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    padding-right: 28px;
}

.popup-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(155, 117, 255, 0.86);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex: 0 0 auto;
}

.popup-title-wrap {
    min-width: 0;
    flex: 1;
}

.popup-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.popup-place {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.35;
    color: #7a7f8e;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.popup-message {
    font-size: 15px;
    line-height: 1.45;
    color: #1f1f24;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    border: 0;
    background: transparent;
    color: #6d6e77;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.temp-card {
    width: 236px;
    padding: 12px;
}

.temp-card-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.temp-card-actions {
    display: flex;
    gap: 8px;
}

.temp-card-actions button {
    flex: 1;
    height: 38px;
    border-radius: 12px;
    border: 0;
    cursor: pointer;
    font-weight: 700;
}

.temp-primary {
    background: linear-gradient(90deg, var(--purple), #6b34ff);
    color: #fff;
}

.temp-secondary {
    background: #eef1f7;
    color: #242733;
}

.preview-marker {
    filter: drop-shadow(0 10px 18px rgba(94, 44, 255, 0.45));
}

.yandex-logo,
a[href*="yandex.ru/maps"],
a[href*="yandex.com/maps"],
[class*="ymaps"][class*="copyright"],
[class*="copyrights-pane"] {
    display: none !important;
}

@media (max-width: 860px) {
    .top-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .provider-switch {
        align-self: flex-start;
    }

    .search-box {
        width: 100%;
    }

    .search-results {
        width: calc(100% - 46px);
    }

    .pick-sidecard {
        top: auto;
        bottom: 96px;
        left: 12px;
        right: 12px;
        width: auto;
        transform: none;
    }

    .pick-point-card {
        min-width: 0;
        width: min(280px, calc(100vw - 24px));
        max-width: min(280px, calc(100vw - 24px));
    }
}

@media (max-width: 720px) {
    .top-controls {
        top: 14px;
        left: 14px;
        right: 14px;
        gap: 10px;
    }

    .provider-switch {
        align-self: stretch;
        width: 100%;
    }

    .provider-btn {
        flex: 1;
    }

    .search-results {
        width: calc(100% - 46px);
        max-height: min(54vh, 420px);
    }

    .search-item {
        padding: 11px 10px 10px;
    }

    .search-title {
        font-size: 14px;
    }

    .search-subtitle,
    .search-message {
        font-size: 12px;
    }

    .bottom-controls {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .trace-button {
        flex: 1;
        min-width: 0;
    }

    .trace-modal {
        width: min(100%, calc(100vw - 20px));
        padding: 16px;
    }

    .popup-card {
        width: min(350px, calc(100vw - 30px));
    }
}
