/* Мобильный вид навигатора и панели маршрута.
 *
 * Отдельный файл: в index.html стили писались под компьютер, и дописывать
 * мобильные правила вперемешку с ними — верный способ сломать десктоп.
 *
 * Два правила, которые держат весь этот файл:
 *   * всё, что нажимают на ходу, — не меньше 48px: палец не курсор, а в
 *     машине он ещё и трясётся;
 *   * низ и верх уважают safe-area — у телефонов с чёлкой и полоской жеста
 *     угол экрана физически недоступен, кнопка там просто не нажмётся.
 */

/* ---------- панель маршрута: лист снизу вместо «пилюли» ---------- */
/* Пилюля висела под шапкой — то есть у самого дальнего от пальца края.
   Всё, что нажимают, переезжает вниз, в зону большого пальца. */
.route-panel {
  position: fixed;
  left: 8px; right: 8px; bottom: 0;
  top: auto; transform: none;
  width: auto; max-width: none;
  margin-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: #0b1220;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 18px;
  padding: 12px 14px 14px;
  box-shadow: 0 -6px 28px rgba(0, 0, 0, .45);
  z-index: 1300;
  display: none;
  gap: 10px;
  white-space: normal;
  font-size: 14px;
}
.route-panel.show { display: block; }
body.d3active #routePanel { z-index: 1300; top: auto; bottom: 0; }

#routeTitle {
  font-size: 15px; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#routeInfo {
  display: block; font-size: 20px; font-weight: 700;
  color: #7fc4ff; margin: 2px 0 10px;
}
#routeBtns { display: flex; align-items: center; gap: 8px; }

/* Кнопки панели: прямоугольные и крупные вместо кружков 24px. */
.route-panel button {
  background: #1b2740; border: 1px solid #2e4066; color: #fff;
  min-width: 52px; height: 52px; border-radius: 14px;
  font-size: 20px; display: flex; align-items: center; justify-content: center;
  padding: 0 12px; cursor: pointer; flex: none;
}
.route-panel button:active { background: #27365a; }
#routeGo {
  flex: 1; background: #0969da; border-color: #0969da;
  font-size: 16px; font-weight: 700; gap: 8px;
}
#routeGo:active { background: #0b5ed7; }
#routeClose { background: transparent; border-color: #3a4a70; font-size: 17px; }

/* Кнопка «в навигатор телефона» — заметная, но уже не главная:
   главная теперь «Вести», и пульс перешёл бы ей дорогу. */
#routeNav { background: #fff; color: #0969da; border-color: #fff; animation: none; }

/* ---------- режим ведения ---------- */
#navBox {
  display: none; position: fixed; z-index: 1400;
  left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top, 0px));
  background: rgba(8, 13, 24, .95);
  backdrop-filter: blur(10px);
  color: #fff; border-radius: 18px; padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55);
}
#navBox.show { display: block; }

#navTop { display: flex; align-items: center; gap: 14px; }
#navArrow { font-size: 46px; line-height: 1; color: #4da3ff; flex: none; width: 52px; text-align: center; }
#navDist { font-size: 34px; font-weight: 800; line-height: 1 }
#navText { color: #c3d6ea; margin-top: 4px; font-size: 15px; line-height: 1.25 }

/* Подсказка о следующем манёвре: водителю нужно знать не только текущий
   поворот, но и что сразу за ним — иначе после поворота он не успевает
   перестроиться. */
#navNext {
  display: none; margin-top: 10px; padding-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, .12);
  color: #8fa9c4; font-size: 13px;
}
#navNext.show { display: block; }

/* Нижняя плашка — отдельно от верхней: цифры поездки смотрят вниз,
   манёвр вверх, и взгляд не ищет их в одном нагромождении. */
#navBar {
  display: none; position: fixed; z-index: 1400;
  left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(8, 13, 24, .95); backdrop-filter: blur(10px);
  color: #fff; border-radius: 18px; padding: 10px 12px;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, .5);
  align-items: center; gap: 10px;
}
#navBar.show { display: flex; }
#navStats { flex: 1; min-width: 0 }
#navEta { font-size: 19px; font-weight: 700; line-height: 1.1 }
#navRest { color: #9fb6cc; font-size: 13px; margin-top: 2px }
#navBar button {
  border: none; color: #fff; min-width: 52px; height: 52px;
  border-radius: 14px; font-size: 20px; cursor: pointer; flex: none;
  display: flex; align-items: center; justify-content: center;
}
#navMuteBtn, #navCenterBtn { background: #1b2740 }
#navStopBtn { background: #d13438; font-size: 15px; font-weight: 700; padding: 0 16px }

/* Камеру можно отпустить и посмотреть карту руками; кнопка возвращает
   слежение. Без неё любое касание карты ломало бы навигацию насовсем. */
#navCenterBtn.off { background: #0969da }

/* В режиме ведения всё лишнее убирается: на ходу читают дорогу, а не
   фильтры по районам. */
body.navigating #topbar,
body.navigating .layers-ctrl,
body.navigating #hdr3d,
body.navigating #routePanel,
body.navigating .maplibregl-ctrl-bottom-left,
body.navigating .leaflet-control-zoom { display: none !important; }

/* Слои в ведении: открываются по #navBaseBtn (полная панель 2D/3D + подложка).
   Раскрытую панель не прячем и поднимаем над рельсом (#navCtl 1400) и карточкой (#navTgt 1450). */
body.navigating .layers-ctrl.lcu.open { display: block !important; z-index: 1500; }

/* Альбомная ориентация: по высоте места нет, поэтому манёвр слева,
   цифры справа, карта между ними. */
@media (orientation: landscape) and (max-height: 500px) {
  #navBox { right: auto; width: 46%; max-width: 330px }
  #navArrow { font-size: 36px; width: 40px }
  #navDist { font-size: 26px }
  #navBar { left: auto; width: 46%; max-width: 330px }
}

/* Компьютер: панели не растягиваются на всю ширину экрана. */
@media (min-width: 700px) {
  .route-panel { left: auto; right: 14px; width: 360px; bottom: 14px }
  #navBox { left: auto; right: 14px; width: 360px }
  #navBar { left: auto; right: 14px; width: 360px }
}

/* ---------- правки по живой проверке на экране 375x812 ---------- */
/* Три кнопки по 52px съедали половину плашки, и «10:57 · 4 мин» ломалось
   на три строки. Цифры — главное в этой плашке, им и место. */
#navEta, #navRest { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
#navEta { font-size: 17px }
#navBar button { min-width: 46px; height: 46px }
#navStopBtn { font-size: 14px; padding: 0 12px }

/* В режиме ведения сотни точек POI поверх дороги мешают видеть сам маршрут.
   Не прячем совсем — они подсказывают, где ты едешь, — но уводим в фон. */
body.navigating .leaflet-marker-icon:not(.nav-puck),
body.navigating .marker-cluster { opacity: .28 }
body.navigating .nav-puck { opacity: 1 }

/* Слово «Завершить» съедало 110px из 375, и часы прибытия превращались в
   «10:57 · …». На узком экране крест понятен без слова, на широком слово
   возвращается. */
#navStopBtn { font-size: 0; min-width: 46px; padding: 0 }
#navStopBtn::before { content: '\2715'; font-size: 19px }
@media (min-width: 420px) {
  #navStopBtn { font-size: 14px; padding: 0 14px }
  #navStopBtn::before { content: none }
}

/* #navBar button (id + тег) специфичнее, чем #navStopBtn (один id), поэтому
   прошлое правило проигрывало и слово оставалось видимым рядом с крестом. */
#navBar #navStopBtn { font-size: 0; min-width: 46px; padding: 0 }
#navBar #navStopBtn::before { content: '\2715'; font-size: 19px }
@media (min-width: 420px) {
  #navBar #navStopBtn { font-size: 14px; padding: 0 14px }
  #navBar #navStopBtn::before { content: none }
}

/* ---------- колонка управления в режиме ведения ---------- */
/* «Нет кнопки моего местоположения, нет выбора языка» — они были: ◎ в
   нижней плашке и флаг в шапке. Но шапка в ведении скрыта целиком, а ◎
   опознать невозможно, поэтому обе кнопки считались отсутствующими.
   Теперь они стоят столбиком у правого края: место, где их ищет большой
   палец, и единственное направление, в котором плашке не тесно. */
#navCtl {
  display: none; position: fixed; z-index: 1400;
  right: 8px; bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  flex-direction: column; gap: 10px;
}
body.navigating #navCtl { display: flex; }
/* Единый стиль правых кнопок с рельсом карты (.rb): 46×46, #16263A, радиус 14,
   тень 0 4px 18px — чтобы при переходе карта↔навигация кнопки не «переезжали» по виду. */
#navCtl button {
  width: 46px; height: 46px; border-radius: 14px;
  border: 0;
  background: #16263A;
  color: #E6F1FF; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .45);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
#navCtl button:active { background: #27365a; }
/* Синяя — значит «камера отпущена, нажми чтобы вернуть слежение».
   Спокойный цвет = слежение уже идёт, жать не надо. */
#navCenterBtn.off { background: #0969da; border-color: #0969da; }
#navLangBtn { font-size: 20px; }

/* Кнопки уехали из плашки, и прежние уступки тесноте больше не нужны:
   «Завершить» снова пишется словом, высота вернулась к 52px. */
#navBar #navStopBtn { font-size: 15px; min-width: 112px; padding: 0 18px; height: 52px }
#navBar #navStopBtn::before { content: none }
#navEta { font-size: 20px }
#navRest { font-size: 14px }

/* Альбомная: плашки сужены до 46%, колонка встаёт выше них. */
@media (orientation: landscape) and (max-height: 500px) {
  #navCtl { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- карточка объекта: клик по метке во время ведения ---------- */
/* Лист снизу, а не всплывашка у метки: метку закрывает палец, а нижний
   край — единственное место, куда дотягиваются не отрывая руки. */
#navTgt {
  display: none; position: fixed; z-index: 1450;
  left: 8px; right: 8px; bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  background: rgba(8, 13, 24, .97); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 18px;
  padding: 13px 15px; color: #fff;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .6);
}
#navTgt.show { display: block; }
#navTgt .nm { font-size: 16px; font-weight: 700 }
#navTgt .ad { color: #9fb6cc; font-size: 13px; margin-top: 2px }
#navTgt .dd { color: #7fc4ff; font-size: 14px; margin-top: 5px; min-height: 19px }
#navTgt .bb { display: flex; gap: 8px; margin-top: 12px }
#navTgt .go {
  flex: 1; height: 50px; border: none; border-radius: 14px;
  background: #0969da; color: #fff; font: 700 16px/1 inherit; cursor: pointer;
  touch-action: manipulation;
}
/* Ждём маршрут — видно, что кнопка ещё не готова, а не «не нажимается». */
#navTgt .go:disabled { background: #223354; color: #8ca0b8; cursor: default }
#navTgt .no {
  width: 96px; height: 50px; border-radius: 14px; cursor: pointer;
  background: transparent; color: #c3d6ea; border: 1px solid #3a4a70;
  font: 15px/1 inherit; touch-action: manipulation;
}

/* Пока карточка открыта, кнопки и спидометр поднимаются над ней. Иначе
   карточка легла бы ровно на «Где я» и на скорость — на то самое, чем
   пользуются, не глядя. */
body:has(#navTgt.show) #navCtl { bottom: calc(252px + env(safe-area-inset-bottom, 0px)) }
body:has(#navTgt.show) #navSpeed { bottom: calc(252px + env(safe-area-inset-bottom, 0px)) }
body:has(#navTgt.show) #navHaz { bottom: calc(272px + env(safe-area-inset-bottom, 0px)) }

@media (min-width: 700px) {
  #navTgt { left: auto; right: 14px; width: 360px }
}

/* ================= главный экран: раскладка навигаторов ================= */
/* По образцу MAPS.ME: частое — внизу, под большим пальцем; сверху — только
   поиск. В шапке было шесть элементов на 375px, и поле поиска сжималось
   до двух букв «Пс». Кнопки никуда не делись: они спрятаны и нажимаются
   из новых мест (см. ui.js), со всеми прежними обработчиками. */
#topbar .home-btn, #geoBtn, #btnTheme, #btnAlerts, #langBtn { display: none !important }

/* Круглые кнопки по краям карты. */
.fab {
  position: fixed; z-index: 950; width: 52px; height: 52px; border-radius: 50%;
  border: none; background: #fff; color: #1f2937; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .22); touch-action: manipulation;
}
.fab:active { background: #eef2f7 }
.fab-layers { left: 12px; top: 124px }
.fab-loc { right: 12px; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); color: #0969da }

/* Слои — всплывают по кнопке, а не висят всегда: раскрытая панель
   закрывала четверть карты. */
.layers-ctrl { display: none; left: 74px; right: auto; top: 124px;
  border-radius: 14px; min-width: 176px; box-shadow: 0 8px 28px rgba(0, 0, 0, .25) }
.layers-ctrl.open { display: block }
.layers-ctrl button { padding: 13px 15px; font-size: 15px }

/* Масштаб — справа посередине, крупнее: в углу у левого края его
   доставал только второй рукой. */
.leaflet-top.leaflet-left { top: 50%; left: auto; right: 12px; transform: translateY(-50%) }
.leaflet-control-zoom { border: none !important; border-radius: 26px !important; overflow: hidden;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .22) !important; margin: 0 !important }
.leaflet-control-zoom a { width: 52px !important; height: 50px !important;
  line-height: 50px !important; font-size: 24px !important }

/* «© OpenStreetMap» прятать под вкладками нельзя: показ атрибуции —
   условие лицензии OSM. Поднимаем её над панелью. */
.leaflet-bottom { bottom: calc(80px + env(safe-area-inset-bottom, 0px)) }

/* Нижние вкладки — плавающая плашка, как у MAPS.ME. */
.tabbar {
  position: fixed; z-index: 1000; left: 10px; right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex; background: #fff; border-radius: 22px; padding: 6px 4px;
  box-shadow: 0 4px 22px rgba(0, 0, 0, .18);
}
.tab {
  flex: 1; min-width: 0; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 2px; min-height: 56px; color: #374151;
  font: 600 11.5px/1.15 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  touch-action: manipulation; border-radius: 14px;
}
.tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100% }
.tab:active { background: rgba(9, 105, 218, .08) }
.tab.on { color: #0969da }

/* Лист «Ещё» — значение справа в строке (язык, переключатель темы). */
#moreSheet .mv { flex: none; color: #8ca0b8; font-size: 15px }

/* Открыт лист — вкладки уходят под него, а «где я» поднимается над ним:
   иначе лист маршрута лёг бы ровно на панель и на кнопку. */
body:has(#routePanel.show) .tabbar,
body:has(#offlineSheet.show) .tabbar,
body:has(#alertsSheet.show) .tabbar,
body:has(#moreSheet.show) .tabbar { display: none }
body:has(#routePanel.show) .fab-loc { bottom: calc(196px + env(safe-area-inset-bottom, 0px)) }
body:has(#routePanel.show) .leaflet-bottom { bottom: calc(180px + env(safe-area-inset-bottom, 0px)) }

/* В ведении своя раскладка — новые элементы там лишние. */
body.navigating .tabbar, body.navigating .fab,
body.d3active .fab { display: none !important }
/* В 3D нижняя панель нужна: владелец попросил (19.11) */
body.d3active .tabbar { display: flex !important }
body.navigating .leaflet-bottom { bottom: 0 }

body.theme-dark .fab, body.theme-dark .tabbar { background: #1a2438; color: #dde2eb }
body.theme-dark .fab-loc { color: #4da3ff }
body.theme-dark .tab { color: #a8b6c8 }
body.theme-dark .tab.on { color: #4da3ff }
body.theme-dark .leaflet-control-zoom a { background: #1a2438 !important; color: #dde2eb !important;
  border-color: #2a3245 !important }

@media (min-width: 700px) {
  .tabbar { left: 50%; right: auto; width: 520px; transform: translateX(-50%) }
}

/* ================= участники карты (contrib.js) ================= */
.c-form { padding: 6px 16px 16px; display: flex; flex-direction: column; gap: 10px }
.c-f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: #8ca0b8 }
.c-f input, .c-f select, .c-f textarea {
  font: 16px/1.3 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;  /* 16px: iOS не приближает поле */
  padding: 11px 12px; border-radius: 11px; border: 1px solid #2a3550;
  background: #121b2e; color: #fff; outline: none; width: 100%;
}
.c-f input:focus, .c-f select:focus, .c-f textarea:focus { border-color: #0969da }
.c-tabs { display: flex; gap: 6px; padding: 10px 16px 2px }
.c-tabs button { flex: 1; height: 42px; border-radius: 11px; cursor: pointer; font: 600 14px/1 inherit;
  background: #162036; color: #c3d6ea; border: 1px solid #2a3550 }
.c-tabs button.on { background: #0969da; border-color: #0969da; color: #fff }
.c-go { height: 50px; border: none; border-radius: 14px; background: #0969da; color: #fff;
  font: 700 16px/1 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; cursor: pointer; touch-action: manipulation }
.c-go:disabled { background: #223354; color: #8ca0b8 }
.c-close { height: 46px; border-radius: 14px; background: transparent; color: #f0a5a5;
  border: 1px solid #5a2a35; font: 600 14px/1 system-ui, sans-serif; cursor: pointer }
.c-err { color: #ff8b8b; font-size: 13.5px; min-height: 0 }
.c-err:empty { display: none }
.c-lic, .c-loc { color: #8ca0b8; font-size: 12.5px; line-height: 1.4 }
.c-st { flex: none; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 10px; background: #223354; color: #c3d6ea }
.c-st.c-applied { background: #123d24; color: #7ee2a8 }
.c-st.c-rejected { background: #4a1d24; color: #ff9a9a }
.c-out { padding: 14px 16px }

/* «+» слева внизу, как у MAPS.ME: добавить место на карту. */
.fab-add { left: 12px; bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  color: #fff; background: #f08c00; font: 400 30px/1 system-ui, sans-serif }
.fab-add:active { background: #d97c00 }

/* Новое место: булавка в центре карты, внизу «Отмена / Здесь».
   Ставят, двигая карту под булавку, — пальцем по самой точке на
   телефоне точно не попасть. */
.c-pin { display: none; position: absolute; z-index: 1000; left: 50%; top: 50%;
  transform: translate(-50%, -100%); font-size: 40px; pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .45)) }
body.picking .c-pin { display: block }
.c-pickbar { display: none; position: fixed; z-index: 1300; left: 8px; right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px)); background: rgba(8, 13, 24, .96);
  color: #fff; border-radius: 18px; padding: 12px 14px; box-shadow: 0 -8px 28px rgba(0, 0, 0, .5) }
body.picking .c-pickbar { display: block }
.c-pickbar .c-hint { font-size: 14px; margin-bottom: 10px; color: #c3d6ea }
.c-pickbar .c-row { display: flex; gap: 8px }
.c-pickbar .c-go { flex: 1 }
.c-pickbar .ol-sec { height: 50px; border-radius: 14px; padding: 0 18px; background: transparent;
  color: #c3d6ea; border: 1px solid #3a4a70; font: 600 15px/1 system-ui, sans-serif }
body.picking .tabbar, body.picking .fab, body.picking #routePanel { display: none !important }

body:has(.c-sheet.show) .tabbar { display: none }
body.navigating .fab-add, body.d3active .fab-add { display: none !important }
@media (min-width: 700px) { .c-pickbar { left: auto; right: 14px; width: 380px } }

/* ================= компас (compass.js) ================= */
/* Над «где я», как у MAPS.ME. Вкл — синее кольцо. */
.fab-compass { right: 12px; bottom: calc(156px + env(safe-area-inset-bottom, 0px)) }
.fab-compass.on { box-shadow: 0 0 0 3px #0969da, 0 3px 12px rgba(0, 0, 0, .22) }
.fab-compass .needle { display: flex; transition: transform .12s linear }
body:has(#routePanel.show) .fab-compass { bottom: calc(260px + env(safe-area-inset-bottom, 0px)) }
body.picking .fab-compass { display: none }

/* Луч «куда смотрю» на метке «где я». Рисует CSS по углу --heading —
   коду метки знать про компас не нужно. Сужается к точке и тает к краю,
   как у привычных карт. */
body.has-heading .geo-pin { position: relative }
body.has-heading .geo-pin::before {
  content: ''; position: absolute; left: 50%; bottom: 50%; z-index: -1;
  width: 58px; height: 54px; transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(var(--heading, 0deg));
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  background: linear-gradient(to top, rgba(9, 105, 218, .55), rgba(9, 105, 218, 0));
  pointer-events: none;
}

/* ================= меню слоёв: вид и карта ================= */
.layers-ctrl .lc-h { padding: 10px 15px 4px; font-size: 11px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: #8c959f }
.layers-ctrl .lc-h:empty { padding: 0; border-top: 1px solid #e0e6ed; margin-top: 4px }
.layers-ctrl .lc-seg { display: flex; gap: 6px; padding: 2px 10px 6px }
.layers-ctrl .lc-seg button { flex: 1; width: auto; text-align: center; border: 1px solid #d0d7de !important;
  border-radius: 10px; padding: 9px 0; font-weight: 700 }
.layers-ctrl .lc-seg button + button { border-top: 1px solid #d0d7de }
.layers-ctrl small { display: block; font-size: 11px; opacity: .75; margin-top: 2px }
body.theme-dark .layers-ctrl .lc-seg button { border-color: #2a3245 !important }

/* ================= меню правой кнопки, флаги языка ================= */
.ctx-pop .leaflet-popup-content { margin: 6px 0 }
.ctx-pop .leaflet-popup-content-wrapper { border-radius: 12px; padding: 0 }
.ctx-menu { display: flex; flex-direction: column; min-width: 210px }
.ctx-menu button { border: none; background: none; text-align: left; cursor: pointer;
  padding: 10px 16px; font: 500 14.5px/1.2 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: #1f2328 }
.ctx-menu button:hover { background: #f0f3f6 }
.ctx-pop3.maplibregl-popup .maplibregl-popup-content { padding: 6px 0; border-radius: 12px; color: #1f2328 }
.ctx-pop3:not(.ctx-pop3m).maplibregl-popup .maplibregl-popup-content { padding: 10px 12px }

.lang-flags { position: fixed; z-index: 950; right: 12px; top: 124px; display: flex; gap: 4px;
  background: #fff; border-radius: 12px; padding: 5px; box-shadow: 0 3px 12px rgba(0, 0, 0, .22) }
.lang-flags button { border: 2px solid transparent; border-radius: 6px; padding: 2px; background: none;
  cursor: pointer; line-height: 0; opacity: .55; touch-action: manipulation }
.lang-flags button svg { border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12) }
.lang-flags button.on { border-color: #0969da; opacity: 1 }
body.theme-dark .lang-flags { background: #1a2438 }
body.navigating .lang-flags, body.d3active .lang-flags, body.picking .lang-flags { display: none }

/* ================= профиль, избранное, сохранённые точки ================= */
/* Кнопка профиля — в ряду флагов, только на широком экране; на телефоне
   профиль открывается из листа «Ещё». */
.lang-flags .pf-btn { display: none; border: none; background: none; cursor: pointer; color: #374151;
  border-left: 1px solid #d0d7de; border-radius: 0; margin-left: 3px; padding: 0 3px 0 9px; line-height: 0;
  touch-action: manipulation }
body.signed-in .lang-flags .pf-btn { color: #0969da }
body.theme-dark .lang-flags .pf-btn { color: #dde2eb; border-left-color: #2a3245 }
body.theme-dark.signed-in .lang-flags .pf-btn { color: #4da3ff }
@media (min-width: 700px) { .lang-flags .pf-btn { display: block } }

.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px 16px }
.pf-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; text-align: left;
  min-height: 96px; padding: 14px; border-radius: 16px; border: 1px solid #2a3550; background: #162036;
  color: #fff; cursor: pointer; font: 600 15px/1.25 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  touch-action: manipulation }
.pf-tile:active { background: #1d2b48 }
.pf-tile .pf-i { font-size: 27px; line-height: 1 }
.pf-tile small { color: #8ca0b8; font-weight: 400; font-size: 12.5px }
.pf-tile small:empty { display: none }

.sv-del { flex: none; width: 40px; height: 40px; border-radius: 12px; border: none; background: transparent;
  color: #8ca0b8; font-size: 16px; cursor: pointer; touch-action: manipulation }
.sv-del:active { background: rgba(255, 255, 255, .08) }
#savedSheet .as-tx b { overflow-wrap: anywhere }

/* Сохранённая точка на карте. */
.pt-star { width: 28px; height: 28px; border-radius: 50%; background: #f59e0b; color: #fff; font-size: 16px;
  line-height: 24px; text-align: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4) }

body:has(#profileSheet.show) .tabbar, body:has(#savedSheet.show) .tabbar { display: none }

/* Жалоба на место: причины списком, радио — на всю строку. */
.c-rs { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid #2a3550; background: #162036; color: #fff; font-size: 15px; cursor: pointer }
.c-rs input { width: 20px; height: 20px; accent-color: #0969da; flex: none }

/* кнопка аккаунта */
.pf-btn .pf-ava { width: 28px; height: 28px; font-size: 14px }
.pf-btn .pf-t { margin-left: 6px; font: 600 14px/1 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; vertical-align: 6px }
.lang-flags .pf-btn { display: inline-flex; align-items: center }
/* прицел «новое место» — той же карточкой, что окна */
.c-pickbar { background: #fff; color: #1b2433; border-radius: 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, .3) }
.c-pickbar .c-hint { color: #5b6b82 }
.c-pickbar .ol-sec { color: #4a5a72; border: 1px solid #cfd8e4 }
body.theme-dark .c-pickbar { background: #111a2c; color: #eaf0f8 }
body.theme-dark .c-pickbar .c-hint { color: #9db0c8 }
body.theme-dark .c-pickbar .ol-sec { color: #c3d6ea; border-color: #2a3550 }

/* Определение места: плашка сразу по нажатию и при ошибке — с причиной и «Повторить» */
#navGeo { display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 5000;
  max-width: min(92vw, 460px); align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: #1b2740; color: #fff;
  font: 600 14px/1.35 system-ui, sans-serif; box-shadow: 0 6px 24px rgba(0,0,0,.4) }
#navGeo.show { display: flex }
#navGeo.err { background: #7a1f24 }
#navGeo button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: rgba(255,255,255,.22); color: #fff; font: 700 14px system-ui, sans-serif; cursor: pointer; flex: none }
#navGeo button.x { min-width: 44px; padding: 0; background: transparent }

/* Плашка определения места: текст на всю ширину, кнопки в ряд */
#navGeo { flex-wrap: wrap; justify-content: flex-end }
#navGeo span { flex: 1 1 100% }
#navGeo button.x { margin-left: auto }

/* Панель «Откуда / Куда» */
#rplan { display: none; position: fixed; z-index: 1500; left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top, 0px)); max-height: calc(100dvh - 16px); overflow: auto;
  background: #fff; color: #1f2328; border-radius: 16px; padding: 10px 44px 10px 10px; box-shadow: 0 8px 30px rgba(0,0,0,.28); font: 14px/1.3 system-ui, sans-serif }
#rplan.show { display: block }
#rplan .rp-row { display: flex; align-items: center; gap: 6px }
#rplan .rp-dot, .rp-pin { flex: none; width: 26px; height: 26px; border-radius: 50%; color: #fff; font: 700 13px/26px system-ui, sans-serif; text-align: center }
.rp-pin { box-shadow: 0 0 0 3px #fff, 0 2px 8px rgba(0,0,0,.45) }
.rp-dot.from, .rp-pin.from { background: #1a7f37 }
.rp-dot.to, .rp-pin.to { background: #cf222e }
#rplan .rp-fld { flex: 1; min-width: 0; display: flex; flex-direction: column }
#rplan .rp-fld label { font-size: 11px; color: #57606a }
#rplan .rp-fld input { width: 100%; box-sizing: border-box; min-height: 40px; padding: 0 10px; border: 1px solid #d0d7de; border-radius: 10px; background: #f6f8fa; color: inherit; font: 15px system-ui, sans-serif }
#rplan .rp-fld input.me::placeholder { color: #0969da; opacity: 1; font-weight: 600 }
#rplan .rp-b { flex: none; width: 44px; height: 44px; border: 0; border-radius: 10px; background: #eaeef2; font-size: 18px; cursor: pointer }
#rplan .rp-swap { display: block; margin: 2px 0 2px 2px; width: 44px; height: 32px; border: 0; border-radius: 10px; background: transparent; font-size: 22px; color: #0969da; cursor: pointer }
#rplan .rp-x { position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; border: 0; background: transparent; font-size: 18px; color: #57606a; cursor: pointer }
#rplan .rp-sr { display: none; margin-top: 6px; border-top: 1px solid #eaeef2; max-height: 40dvh; overflow: auto }
#rplan .rp-sr.show { display: block }
#rplan .rp-it { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 6px; min-height: 44px; cursor: pointer; color: inherit; font: inherit; border-bottom: 1px solid #f0f2f4 }
#rplan .rp-it:hover { background: #f6f8fa }
#rplan .rp-it small { display: block; color: #57606a; font-size: 12px }
#rplan .rp-empty { padding: 12px 6px; color: #57606a }
#rplanPick { display: none; position: fixed; z-index: 1500; left: 50%; transform: translateX(-50%); top: calc(10px + env(safe-area-inset-top, 0px)); max-width: 92vw; align-items: center; gap: 8px;
  padding: 8px 8px 8px 16px; border-radius: 24px; background: #0969da; color: #fff; font: 600 14px system-ui, sans-serif; box-shadow: 0 6px 20px rgba(0,0,0,.35) }
#rplanPick.show { display: flex }
#rplanPick button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.25); color: #fff; font-size: 16px; cursor: pointer }
body.rp-picking #map, body.rp-picking .maplibregl-canvas { cursor: crosshair !important }
body.rp-picking .tabbar, body.rp-picking #routePanel { display: none !important }
body.rp-open .tabbar { display: none }
body.theme-dark #rplan { background: #1a2438; color: #dde2eb }
body.theme-dark #rplan .rp-fld input { background: #0f1628; border-color: #34425c }
body.theme-dark #rplan .rp-b { background: #26324a; color: #fff }
body.theme-dark #rplan .rp-it { border-color: #26324a } body.theme-dark #rplan .rp-it:hover { background: #26324a }
#navGeo { width: min(92vw, 460px); box-sizing: border-box }
#navGeo button:not(.x) { flex: 1 1 auto }
body.navigating #rplan, body.navigating #rplanPick { display: none !important }
/* Выбор точки: метки и кластеры не ловят нажатие — оно уходит в карту и только ставит точку */
body.rp-picking .leaflet-marker-pane *, body.rp-picking .leaflet-shadow-pane *, body.rp-picking .leaflet-popup { pointer-events: none !important }
body.rp-picking .cluster-tip { display: none !important }

#navCloseBtn { background: #d13438 !important; border-color: #d13438 !important; font-size: 20px; font-weight: 700 }

/* Демо-проезд: кнопка скорости ×1/×4 видна только в нём; метка на плашке */
#navDemoBtn { display: none !important; font-size: 16px; font-weight: 700 }
body.nav-demo #navDemoBtn { display: flex !important }

/* Выбор из нескольких маршрутов: строки в листе и серые линии на карте */
#routeAlts { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 }
#routeAlts:empty { display: none }
.rt-chip { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: inherit; font: 600 13px system-ui, sans-serif; cursor: pointer; touch-action: manipulation }
.rt-chip.on { background: #fff; color: #0969da; border-color: #fff }
.leaflet-overlay-pane path.rt-alt { cursor: pointer }
.route-panel #routeAlts .rt-chip, .route-panel #routeMore .rt-chip, .route-panel #routePref .rt-chip { width: auto; white-space: nowrap; height: auto; min-height: 36px; min-width: 0; padding: 0 12px; font-size: 13px; border-radius: 18px; flex: 0 0 auto; display: inline-flex; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.35) }
.route-panel #routeAlts .rt-chip.on, .route-panel #routeMore .rt-chip.on, .route-panel #routePref .rt-chip.on { background: #fff; color: #0969da; border-color: #fff }

/* Дом / работа / недавние в панели «Откуда / Куда» */
#rplan .rp-qrow { display: flex; align-items: center; border-bottom: 1px solid #f0f2f4 }
#rplan .rp-qrow .rp-it { flex: 1; border-bottom: 0 }
#rplan .rp-qset { flex: none; min-height: 36px; margin-right: 4px; padding: 0 10px; border: 1px solid #d0d7de; border-radius: 10px; background: #fff; color: #0969da; font: 600 13px system-ui, sans-serif; cursor: pointer }
#rplan .rp-hd { padding: 8px 6px 2px; font-size: 12px; color: #57606a }
body.theme-dark #rplan .rp-qset { background: #26324a; color: #7fc4ff; border-color: #34425c }
#routeMore { display: flex; gap: 6px; margin: 0 0 8px }
#routeMore:empty { display: none }

body:has(#navTgt.show) #navLim { bottom: calc(252px + env(safe-area-inset-bottom, 0px)) }

/* Промежуточные остановки в панели «Откуда / Куда» */
#rplan .rp-via:empty { display: none }
#rplan .rp-vi { display: flex; align-items: center; gap: 6px; margin: 2px 0 2px 32px; padding: 4px 6px; border: 1px solid #e0e6ed; border-radius: 10px; background: #fafbfc; cursor: grab }
#rplan .rp-vi.drag { opacity: .45 }
#rplan .rp-vi b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px }
#rplan .rp-vi button { flex: none; width: 36px; height: 36px; border: 0; border-radius: 8px; background: #eaeef2; color: #1f2328; font-size: 13px; cursor: pointer }
#rplan .rp-vn, .rp-pin.via { background: #f59e0b; color: #fff; font: 700 12px/22px system-ui, sans-serif; text-align: center; border-radius: 50%; flex: none }
#rplan .rp-vn { width: 22px; height: 22px }
.rp-pin.via { width: 26px; height: 26px; line-height: 26px; font-size: 13px }
#rplan .rp-dot.via { background: #f59e0b }
#rplan .rp-add { display: block; margin: 4px 0 4px 32px; min-height: 36px; padding: 0 12px; border: 1px dashed #0969da; border-radius: 10px; background: transparent; color: #0969da; font: 600 13px system-ui, sans-serif; cursor: pointer }
body.theme-dark #rplan .rp-vi { background: #1f2a40; border-color: #34425c } body.theme-dark #rplan .rp-vi button { background: #26324a; color: #fff }

/* «Что рядом» */
#nearSheet { display: none; position: fixed; z-index: 1450; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); max-height: 58dvh; flex-direction: column;
  background: #fff; color: #1f2328; border-radius: 16px; box-shadow: 0 -4px 24px rgba(0,0,0,.28); font: 14px/1.3 system-ui, sans-serif }
#nearSheet.show { display: flex }
#nearSheet .nr-h { display: flex; align-items: center; padding: 10px 8px 4px 14px }
#nearSheet .nr-h b { flex: 1; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
#nearSheet .nr-x { width: 40px; height: 40px; border: 0; background: transparent; font-size: 18px; color: #57606a; cursor: pointer }
#nearSheet .nr-chips { display: flex; gap: 6px; padding: 0 10px 8px; overflow-x: auto; flex: none }
#nearSheet .nr-chip { flex: none; min-height: 36px; padding: 0 12px; border: 1px solid #d0d7de; border-radius: 18px; background: #fff; color: inherit; font: 600 13px system-ui, sans-serif; cursor: pointer }
#nearSheet .nr-chip.on { background: #0969da; border-color: #0969da; color: #fff }
#nearSheet .nr-list { overflow-y: auto; padding: 0 6px 8px }
#nearSheet .nr-it { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 8px; border: 0; border-bottom: 1px solid #f0f2f4; background: none; text-align: left; color: inherit; font: inherit; cursor: pointer }
#nearSheet .nr-n { flex: 1; min-width: 0 }
#nearSheet .nr-n b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
#nearSheet .nr-n small { display: block; color: #57606a; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
#nearSheet .nr-d { flex: none; color: #0969da; font-weight: 600; font-size: 13px }
#nearSheet .nr-empty { padding: 18px 8px; color: #57606a; text-align: center }
body.nr-open .tabbar { display: none }
@media (min-width: 700px) { #nearSheet { left: 14px; right: auto; width: 400px; bottom: 14px } }
body.theme-dark #nearSheet { background: #1a2438; color: #dde2eb } body.theme-dark #nearSheet .nr-chip { background: #26324a; border-color: #34425c; color: #dde2eb }
body.theme-dark #nearSheet .nr-it { border-color: #26324a }

/* Вопрос про язык голоса после смены языка интерфейса */
#navAsk { display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom, 0px)); z-index: 5000; width: min(92vw, 460px); box-sizing: border-box; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: #1b2740; color: #fff; font: 600 14px/1.35 system-ui, sans-serif; box-shadow: 0 6px 24px rgba(0,0,0,.4) }
#navAsk.show { display: flex }
#navAsk span { flex: 1 }
#navAsk button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: #0969da; color: #fff; font: 700 14px system-ui, sans-serif; cursor: pointer }
#navAsk button.x { min-width: 44px; padding: 0; background: transparent }

/* Кнопка очистки ✕ в полях ввода: кружок 36 px, зона нажатия 44×44 */
.sc-x { display: none; position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #57606a; font-size: 15px; line-height: 1; cursor: pointer; z-index: 2; touch-action: manipulation }
.sc-x::after { content: ''; position: absolute; inset: -4px }
.sc-x.show { display: flex; align-items: center; justify-content: center }
.sc-x:hover { background: rgba(127,127,127,.18) }
#rplan .rp-fld .sc-x { top: auto; bottom: 2px; transform: none }
#rplan .rp-fld input { padding-right: 40px }
#hdr3d-filters .sc-x { color: #cbd5e1 }
#q3d { padding-right: 38px !important }

/* «Вернуться к маршруту» на паузе слежения */
#navResume { display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 1500; min-height: 48px; padding: 0 20px;
  border: 0; border-radius: 24px; background: #0969da; color: #fff; font: 700 15px system-ui, sans-serif; box-shadow: 0 4px 18px rgba(0,0,0,.45); cursor: pointer; touch-action: manipulation }
#navResume.show { display: block }

/* ===== Боковая панель маршрута на компьютере (≥700 px): левая колонка на всю высоту, карта остаётся видна ===== */
#rplan .sp-sec, #rplan .sp-ar2 .sp-reset, #spTab { display: none }
@media (min-width: 700px) {
  #rplan { left: 0; right: auto; top: 0; bottom: 0; width: 400px; max-height: none; border-radius: 0; padding: 12px 14px 24px; box-shadow: 4px 0 24px rgba(15, 23, 42, .22); transition: transform .25s cubic-bezier(.2, .8, .2, 1) }
  #rplan .rp-x { top: 10px; right: 10px }
  #rplan .sp-sec { display: block }
  #rplan .sp-ar2 { display: flex; align-items: center; justify-content: space-between; gap: 8px }
  #rplan .sp-ar2 .rp-add { margin-right: 0 }
  #rplan .sp-ar2 .sp-reset { display: block; flex: none; min-height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: #57606a; font: 600 13px system-ui, sans-serif; cursor: pointer }
  #rplan .sp-ar2 .sp-reset:hover { background: #eaeef2 }
  #rplan .sp-along { padding-right: 44px; margin-bottom: 8px }
  #rplan .sp-along input { width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid #d0d7de; border-radius: 20px; background: #f6f8fa; color: inherit; font: 14px system-ui, sans-serif }
  #rplan .sp-arr:empty { display: none }
  #rplan .sp-modes { display: flex; gap: 6px; margin: 0 0 10px }
  #rplan .sp-modes button { flex: 1; min-height: 40px; border: 1px solid #d0d7de; border-radius: 10px; background: #fff; color: inherit; font: 600 14px system-ui, sans-serif; cursor: pointer }
  #rplan .sp-modes button.on { background: #0969da; border-color: #0969da; color: #fff }
  #rplan .rp-sr.show ~ .sp-sec { display: none }
  #rplan .sp-params:not(.has), #rplan .sp-acts:not(.has), #rplan .sp-phone:not(.show) { display: none }
  #rplan .sp-params { margin-top: 10px; border-top: 1px solid #eaeef2; padding-top: 8px }
  #rplan .sp-params summary { min-height: 36px; display: flex; align-items: center; cursor: pointer; font-weight: 600 }
  #rplan .sp-prow { display: flex; align-items: center; gap: 8px; padding: 6px 0 4px }
  #rplan .sp-prow label { flex: none; color: #57606a }
  #rplan .sp-prow input { flex: 1; min-width: 0; min-height: 36px; border: 1px solid #d0d7de; border-radius: 8px; padding: 0 8px; background: #f6f8fa; color: inherit; font: 14px system-ui, sans-serif }
  #rplan .sp-prow button { flex: none; min-height: 36px; padding: 0 10px; border: 1px solid #d0d7de; border-radius: 8px; background: #fff; color: #0969da; font: 600 13px system-ui, sans-serif; cursor: pointer }
  #rplan .sp-list { margin-top: 8px }
  #rplan .sp-rt { border: 1px solid #d0d7de; border-radius: 12px; margin-bottom: 8px; overflow: hidden }
  #rplan .sp-rt.on { border-color: #0969da; box-shadow: 0 0 0 1px #0969da }
  #rplan .sp-rh { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; width: 100%; padding: 10px 12px 4px; border: 0; background: none; color: inherit; text-align: left; font: 14px system-ui, sans-serif; cursor: pointer }
  #rplan .sp-rh b { font-size: 18px }
  #rplan .sp-rh span { color: #57606a }
  #rplan .sp-rh small { margin-left: auto; font-size: 13px; color: #1a7f37; font-weight: 600 }
  #rplan .sp-more { display: block; padding: 2px 12px 8px; border: 0; background: none; color: #0969da; font: 600 13px system-ui, sans-serif; cursor: pointer }
  #rplan .sp-steps { display: none; margin: 0; padding: 0 12px 10px 34px; font-size: 13px }
  #rplan .sp-rt.open .sp-steps { display: block }
  #rplan .sp-steps li { padding: 4px 0; border-top: 1px solid #f0f2f4 }
  #rplan .sp-steps small { display: block; color: #57606a }
  #rplan .sp-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px }
  #rplan .sp-acts button { flex: 1 1 auto; min-height: 44px; padding: 0 14px; border: 1px solid #d0d7de; border-radius: 10px; background: #fff; color: #0969da; font: 700 14px system-ui, sans-serif; cursor: pointer }
  #rplan .sp-acts button[data-k=go] { background: #0969da; border-color: #0969da; color: #fff }
  #rplan .sp-phone { margin-top: 10px; text-align: center }
  #rplan .sp-qr svg { width: 168px; height: 168px; background: #fff; border-radius: 8px }
  #rplan .sp-phone input { width: 100%; margin: 6px 0; min-height: 36px; padding: 0 8px; border: 1px solid #d0d7de; border-radius: 8px; background: #f6f8fa; color: inherit; font: 12px system-ui, sans-serif }
  #rplan .sp-phone > button { min-height: 40px; padding: 0 16px; border: 1px solid #d0d7de; border-radius: 10px; background: #fff; color: #0969da; font: 700 13px system-ui, sans-serif; cursor: pointer }
  #routePanel { display: none !important }
  body.rp-open:not(.sp-off) .tc, body.pc-open:not(.sp-off) .tc { left: 410px }
  body.sp-off #rplan, body.sp-off .pc { transform: translateX(-102%) }
  #spTab { position: fixed; z-index: 1501; left: 400px; top: 50%; width: 22px; height: 64px; margin-top: -32px; padding: 0; border: 0; border-radius: 0 10px 10px 0; background: #fff; color: #57606a; box-shadow: 4px 0 12px rgba(15, 23, 42, .2); cursor: pointer; transition: left .25s cubic-bezier(.2, .8, .2, 1) }
  #spTab::before { content: '\2039'; font: 700 26px/1 system-ui, sans-serif }
  body.rp-open #spTab, body.pc-open #spTab { display: block }
  body.sp-off #spTab { left: 0 }
  body.sp-off #spTab::before { content: '\203A' }
  body.theme-dark #rplan .sp-along input, body.theme-dark #rplan .sp-prow input, body.theme-dark #rplan .sp-phone input { background: #0f1628; border-color: #34425c }
  body.theme-dark #rplan .sp-modes button, body.theme-dark #rplan .sp-acts button, body.theme-dark #rplan .sp-prow button, body.theme-dark #rplan .sp-phone > button { background: #26324a; border-color: #34425c; color: #7fc4ff }
  body.theme-dark #rplan .sp-modes button.on, body.theme-dark #rplan .sp-acts button[data-k=go] { background: #0969da; color: #fff }
  body.theme-dark #rplan .sp-rt, body.theme-dark #rplan .sp-params { border-color: #34425c }
  body.theme-dark #rplan .sp-rt.on { border-color: #4aa3ff; box-shadow: 0 0 0 1px #4aa3ff }
  body.theme-dark #spTab { background: #1a2438; color: #dde2eb }
}
#rplan .sp-rdh { margin: 8px 0 4px; color: #57606a; font-size: 13px }
#rplan .rd-box { flex-wrap: wrap }
#rplan .rd-box button { font-size: 13px; min-height: 36px }
#rplan .sp-warn { margin: 0 0 8px; padding: 8px 10px; border-radius: 10px; background: #fff4e0; color: #8a4b08; font: 600 13px/1.3 system-ui, sans-serif }
#routePanel .rd-box { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px }
.route-panel #routePref .rt-chip { white-space: normal; text-align: left; line-height: 1.2; padding-top: 6px; padding-bottom: 6px }

/* ===== Компактная боковая панель маршрута на компьютере: ширина по экрану, буквы A/B в полях, режимы значками, варианты строками ===== */
@media (min-width: 700px) {
  :root { --sp-w: clamp(300px, 26vw, 380px) }
  #rplan { width: var(--sp-w); padding: 8px 10px 14px; font-size: 14px }
  #rplan .rp-x { top: 6px; right: 6px; width: 32px; height: 32px }
  #rplan .sp-along { padding-right: 36px; margin-bottom: 6px }
  #rplan .sp-along input { min-height: 34px; font-size: 14px }
  #rplan .sp-modes:not(.rd-box) { gap: 4px; margin: 0 0 6px }
  #rplan .sp-modes:not(.rd-box) button { flex: none; min-width: 52px; min-height: 32px; padding: 0 12px; border-radius: 16px; font-size: 16px }
  #rplan .rp-row { position: relative; gap: 4px }
  #rplan .rp-dot { position: absolute; left: 7px; top: 50%; margin-top: -10px; width: 20px; height: 20px; font-size: 11px; line-height: 20px; z-index: 1; pointer-events: none }
  #rplan .rp-fld label { display: none }
  #rplan .rp-fld input { min-height: 36px; padding: 0 30px 0 34px; border-radius: 8px; font-size: 14px }
  #rplan .rp-b { width: 36px; height: 36px; font-size: 16px; border-radius: 8px }
  #rplan .rp-swap { margin: 0 6px 0 auto; width: 30px; height: 22px; font-size: 16px; line-height: 1 }
  #rplan .sp-ar2 { margin-top: 2px }
  #rplan .sp-ar2 .rp-add { min-height: 28px; margin: 0; padding: 0 4px; border: 0; background: none; color: #0969da; font: 600 12px system-ui, sans-serif }
  #rplan .sp-ar2 .sp-reset { min-height: 28px; padding: 0 6px; font-size: 12px }
  #rplan .sp-params { margin-top: 4px; padding-top: 2px }
  #rplan .sp-params summary { min-height: 28px; font-size: 13px }
  #rplan .sp-prow { padding: 2px 0 }
  #rplan .sp-prow input, #rplan .sp-prow button { min-height: 30px }
  #rplan .sp-rdh { margin: 4px 0 2px; font-size: 12px }
  #rplan .rd-box button { min-height: 28px; font-size: 12px }
  #rplan .sp-list { margin-top: 4px }
  #rplan .sp-rt { border-radius: 8px; margin-bottom: 4px }
  #rplan .sp-rh { padding: 6px 10px; gap: 2px 8px; font-size: 13px }
  #rplan .sp-rh b { font-size: 15px }
  #rplan .sp-rh small { font-size: 12px }
  #rplan .sp-more { display: none }
  #rplan .sp-steps { padding: 0 10px 8px 28px; font-size: 12px }
  #rplan .sp-acts { gap: 4px; flex-wrap: nowrap; margin-top: 6px; position: sticky; bottom: 0; z-index: 2; padding: 6px 0 2px; background: #fff }   /* ряд действий всегда виден, даже при раскрытых шагах */
  body.theme-dark #rplan .sp-acts { background: #1a2438 }
  #rplan .sp-acts button { flex: 1 1 0; min-width: 0; min-height: 34px; padding: 0 3px; border-radius: 8px; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
  #rplan .sp-acts button { flex-grow: .85 }
  #rplan .sp-acts button[data-k=go] { font-weight: 700 }
  #rplan .sp-acts button[data-k=sp_phone] { flex-grow: 1.4 }
  #rplan .sp-warn { margin: 0 0 4px; padding: 5px 8px; font-size: 12px }
  body.rp-open:not(.sp-off) .tc, body.pc-open:not(.sp-off) .tc { left: calc(var(--sp-w) + 10px) }
  #spTab { left: var(--sp-w) }
}
@media (min-width: 700px) and (max-height: 800px) {
  #rplan { padding-top: 6px }
  #rplan .sp-along input { min-height: 30px }
  #rplan .sp-modes:not(.rd-box) { margin-bottom: 4px }
  #rplan .sp-modes:not(.rd-box) button { min-height: 28px }
  #rplan .rp-fld input { min-height: 32px }
  #rplan .rp-b { width: 32px; height: 32px }
  #rplan .sp-rh { padding: 4px 10px }
  #rplan .sp-acts button { min-height: 30px }
  #rplan .sp-params summary { min-height: 24px }
}

/* Компас в режиме ведения: стрелка показывает север; синяя — север закреплён вверху (3D) или датчик телефона включён (2D) */
#navCompassBtn svg { transition: transform .2s linear; pointer-events: none }
#navCompassBtn.on { background: #0969da; border-color: #0969da }

/* Иконки правых кнопок как у рельса карты: тонкие SVG, наследуют цвет; компас круглый */
#navCtl button svg{width:22px;height:22px;display:block}
#navCtl #navCompassBtn{border-radius:50%}
#navCtl #navCenterBtn{color:#5AA0F7}
#navCtl #navDemoBtn{font-size:15px;font-weight:700}
#navCtl button.on{background:#1E3350;color:#5AA0F7}

/* ==========================================================================
   NavX: раскладки навигатора для широких экранов (планшет / десктоп / авто).

   Телефонный портрет (<700px) — эталон, его правила выше и здесь не тронуты.
   Всё ниже — надстройка: она включается на широком экране, а режим выбирает
   nav.js, ставя на <body> один из классов:

     nav-portrait   — экран выше, чем шире (планшет, поворотный BYD);
     nav-compact    — почти квадрат / половина split-screen (960x1080, 640x720);
     nav-wide       — обычный ландшафт 4:3 и 16:9 (1024x600 … 1920x1080);
     nav-ultrawide  — 21:9 и шире (1280x480, 1920x720, 2560x1080);
     nav-ui-car     — отдельный флаг «головное устройство» (тач/Android-WebView
                      или ?ui=car): крупнее кнопки и текст, тёмный по умолчанию.

   Раскладка выбирается по пропорции экрана (JS), а размеры — через clamp()
   от vh/vw: магнитолы бывают любые (1024x600, 1280x720, 1920x720, 2560x1080),
   фиксированные px под одну модель ломают остальные. Телефоны в ландшафте
   (высота < 421px) намеренно остаются на прежних правилах — там места нет
   ни на что, кроме полосок в углах.
   ========================================================================== */

/* Обёртка левой колонки. На телефоне и в вертикальной раскладке её «нет»:
   display:contents не создаёт бокс, панели остаются теми же fixed-элементами.
   На десктопе/авто обёртка становится колонкой: манёвр сверху, ETA и
   «Завершить» под ним — это и есть «левая панель ведения». */
#navCol { display: contents; }

@media (min-height: 421px) {
  /* ---------- токены размеров: всё от высоты экрана, не от модели ---------- */
  :root {
    --nav-panel-w: clamp(300px, 26vw, 380px);
    --nav-btn: clamp(48px, 5.4vh, 56px);
    --nav-gap: clamp(8px, 1.5vh, 12px);
    --nav-pad: clamp(12px, 1.8vh, 18px);
    --nav-maneuver: clamp(18px, 2.2vh, 22px);
    --nav-dist: clamp(32px, 4.8vh, 44px);
    --nav-eta: clamp(20px, 2.4vh, 24px);
    --nav-rest: clamp(14px, 1.9vh, 17px);
    --nav-nt: clamp(13px, 1.7vh, 16px);
    --nav-edge: 12px;
    --nav-sab: env(safe-area-inset-bottom, 0px);
    --nav-sat: env(safe-area-inset-top, 0px);
    --nav-sal: env(safe-area-inset-left, 0px);
    --nav-sar: env(safe-area-inset-right, 0px);
  }

  /* ================= ПЛАНШЕТ-ПОРТРЕТ / SPLIT-SCREEN (>=700px) =================
     Панель манёвра сверху по центру, карта ниже, снизу горизонтальная плашка
     ETA+«Завершить», справа вертикальный рельс. Тот же порядок, что на
     телефоне, но крупнее — экран больше, а рука так же далеко. */
  @media (min-width: 700px) {
    body.nav-portrait #navBox,
    body.nav-compact #navBox {
      left: 50%; right: auto; transform: translateX(-50%);
      top: calc(var(--nav-edge) + var(--nav-sat));
      width: min(620px, calc(100vw - 2 * var(--nav-edge)));
      padding: var(--nav-pad) calc(var(--nav-pad) + 4px);
      border-radius: 20px;
    }
    body.nav-portrait #navTop,
    body.nav-compact #navTop { gap: 16px }
    body.nav-portrait #navArrow,
    body.nav-compact #navArrow { font-size: clamp(44px, 6vh, 58px); width: 1.25em }
    body.nav-portrait #navDist,
    body.nav-compact #navDist { font-size: var(--nav-dist) }
    body.nav-portrait #navText,
    body.nav-compact #navText { font-size: clamp(17px, 2.2vh, 21px); line-height: 1.3 }
    body.nav-portrait #navNext,
    body.nav-compact #navNext { font-size: var(--nav-nt); margin-top: 12px; padding-top: 10px }

    body.nav-portrait #navBar,
    body.nav-compact #navBar {
      left: 50%; right: auto; transform: translateX(-50%);
      bottom: calc(var(--nav-edge) + var(--nav-sab));
      width: min(620px, calc(100vw - 2 * var(--nav-edge)));
      padding: 10px calc(var(--nav-edge) + 2px);
      border-radius: 18px;
    }
    body.nav-portrait #navBar button,
    body.nav-compact #navBar button {
      min-width: var(--nav-btn); height: var(--nav-btn);
      font-size: clamp(20px, 2.6vh, 24px); border-radius: 14px;
    }
    body.nav-portrait #navBar #navStopBtn,
    body.nav-compact #navBar #navStopBtn {
      font-size: clamp(15px, 2vh, 18px); min-width: clamp(132px, 18vw, 190px);
      height: var(--nav-btn); padding: 0 20px;
    }
    body.nav-portrait #navEta,
    body.nav-compact #navEta { font-size: var(--nav-eta) }
    body.nav-portrait #navRest,
    body.nav-compact #navRest { font-size: var(--nav-rest) }

    body.nav-portrait #navCtl,
    body.nav-compact #navCtl {
      left: auto; right: calc(var(--nav-edge) + var(--nav-sar));
      top: 50%; bottom: auto; transform: translateY(-50%);
      gap: var(--nav-gap);
    }
    body.nav-portrait #navCtl button,
    body.nav-compact #navCtl button {
      width: var(--nav-btn); height: var(--nav-btn); border-radius: 15px;
      font-size: clamp(20px, 2.6vh, 26px);
    }
    body.nav-portrait #navCtl button svg,
    body.nav-compact #navCtl button svg { width: clamp(22px, 2.8vh, 28px); height: clamp(22px, 2.8vh, 28px) }

    /* Спидометр и знак лимита: снизу слева, но НАД плашкой, иначе плашка
       с ETA накрывает скорость — то, на что смотрят чаще всего. */
    body.nav-portrait #navSpeed,
    body.nav-compact #navSpeed {
      left: calc(var(--nav-edge) + var(--nav-sal));
      bottom: calc(var(--nav-edge) + var(--nav-sab) + var(--nav-btn) + 26px);
      width: 84px; height: 84px;
    }
    body.nav-portrait #navSpeedV,
    body.nav-compact #navSpeedV { font-size: 30px }
    body.nav-portrait #navLim,
    body.nav-compact #navLim {
      left: calc(var(--nav-edge) + var(--nav-sal) + 92px);
      bottom: calc(var(--nav-edge) + var(--nav-sab) + var(--nav-btn) + 26px);
    }
    body.nav-portrait #navHaz,
    body.nav-compact #navHaz {
      left: calc(var(--nav-edge) + var(--nav-sal));
      bottom: calc(var(--nav-edge) + var(--nav-sab) + var(--nav-btn) + 118px);
    }
    body.nav-portrait #navTgt,
    body.nav-compact #navTgt {
      left: 50%; right: auto; transform: translateX(-50%);
      width: min(560px, calc(100vw - 2 * var(--nav-edge)));
      bottom: calc(var(--nav-edge) + var(--nav-sab) + var(--nav-btn) + 26px);
    }
    body.nav-portrait #navTgt .go,
    body.nav-compact #navTgt .go { height: var(--nav-btn) }
    body.nav-portrait #navTgt .no,
    body.nav-compact #navTgt .no { height: var(--nav-btn); width: 110px }
    body.nav-portrait #navResume,
    body.nav-compact #navResume { bottom: calc(var(--nav-edge) + var(--nav-sab) + 92px) }
  }

  /* ================= ЛАНДШАФТ 4:3 / 16:9 (nav-wide) =================
     Слева сверху — панель манёвра, по центру снизу — ETA+«Завершить»,
     справа по центру — рельс. Карта между ними. */
  body.nav-wide {
    /* Тач-цели на планшете/десктопе — от 52px: по ним жмут на ходу. */
    --nav-btn: clamp(52px, 6.4vh, 56px);
    --nav-gap: clamp(10px, 1.6vh, 12px);
  }
  body.nav-wide #navBox {
    left: calc(var(--nav-edge) + var(--nav-sal)); right: auto;
    top: calc(var(--nav-edge) + var(--nav-sat));
    width: var(--nav-panel-w);
    padding: var(--nav-pad) calc(var(--nav-pad) + 4px);
    border-radius: 20px;
  }
  body.nav-wide #navTop { gap: 16px }
  body.nav-wide #navArrow { font-size: clamp(40px, 6vh, 54px); width: 1.2em }
  body.nav-wide #navDist { font-size: var(--nav-dist) }
  body.nav-wide #navText { font-size: var(--nav-maneuver); line-height: 1.3 }
  body.nav-wide #navNext { font-size: var(--nav-nt); margin-top: 12px; padding-top: 10px }

  body.nav-wide #navBar {
    left: 50%; right: auto; transform: translateX(-50%);
    bottom: calc(var(--nav-edge) + var(--nav-sab));
    width: min(560px, calc(100vw - 2 * var(--nav-edge)));
    padding: 10px 14px; border-radius: 18px;
  }
  body.nav-wide #navBar button {
    min-width: var(--nav-btn); height: var(--nav-btn);
    font-size: clamp(20px, 2.6vh, 24px); border-radius: 14px;
  }
  body.nav-wide #navBar #navStopBtn {
    font-size: clamp(15px, 2vh, 18px);
    min-width: clamp(132px, 16vw, 180px); height: var(--nav-btn); padding: 0 20px;
  }
  body.nav-wide #navEta { font-size: var(--nav-eta) }
  body.nav-wide #navRest { font-size: var(--nav-rest) }

  body.nav-wide #navCtl {
    left: auto; right: calc(var(--nav-edge) + var(--nav-sar));
    top: 50%; bottom: auto; transform: translateY(-50%);
    gap: var(--nav-gap);
  }
  body.nav-wide #navCtl button {
    width: var(--nav-btn); height: var(--nav-btn); border-radius: 15px;
    font-size: clamp(20px, 2.6vh, 26px);
  }
  body.nav-wide #navCtl button svg { width: clamp(22px, 2.8vh, 28px); height: clamp(22px, 2.8vh, 28px) }

  body.nav-wide #navSpeed {
    left: calc(var(--nav-edge) + var(--nav-sal));
    bottom: calc(var(--nav-edge) + var(--nav-sab));
    width: 84px; height: 84px;
  }
  body.nav-wide #navSpeedV { font-size: 30px }
  body.nav-wide #navLim {
    left: calc(var(--nav-edge) + var(--nav-sal) + 92px);
    bottom: calc(var(--nav-edge) + var(--nav-sab));
  }
  body.nav-wide #navHaz {
    left: calc(var(--nav-edge) + var(--nav-sal));
    bottom: calc(var(--nav-edge) + var(--nav-sab) + 94px);
  }
  body.nav-wide #navTgt {
    left: 50%; right: auto; transform: translateX(-50%);
    width: min(560px, calc(100vw - 2 * var(--nav-edge)));
    bottom: calc(var(--nav-edge) + var(--nav-sab) + 92px);
  }
  body.nav-wide #navTgt .go { height: var(--nav-btn) }
  body.nav-wide #navResume { bottom: calc(var(--nav-edge) + var(--nav-sab)) }

  /* ===== десктоп: панель манёвра и плашка ETA — одна левая колонка ===== */
  @media (min-width: 1100px) {
    body.nav-wide #navCol {
      display: flex; flex-direction: column; gap: 10px;
      position: fixed; z-index: 1400;
      left: calc(var(--nav-edge) + var(--nav-sal));
      top: calc(var(--nav-edge) + var(--nav-sat));
      width: var(--nav-panel-w);
      max-height: calc(100dvh - 2 * var(--nav-edge));
    }
    body.nav-wide #navBox,
    body.nav-wide #navBar {
      position: static; left: auto; right: auto; top: auto; bottom: auto;
      transform: none; width: 100%; margin: 0; box-sizing: border-box;
    }
    body.nav-wide #navBar { flex-wrap: wrap; gap: 12px }
    body.nav-wide #navStats { flex: 1 1 140px }
    body.nav-wide #navBar #navStopBtn { min-width: 100%; height: var(--nav-btn) }
    body.nav-wide #navTgt {
      left: auto; right: calc(var(--nav-edge) + var(--nav-sar) + var(--nav-btn) + 28px);
      transform: none; width: min(520px, 42vw);
    }
    body.nav-wide #navEta { font-size: clamp(22px, 2.6vh, 26px) }
  }

  /* ================= УЛЬТРАВАЙД 21:9 (nav-ultrawide) =================
     Ширины много, высоты мало: колонка слева фиксированной ширины, карта
     занимает центр, рельс справа. Тот же каркас, что на десктопе. */
  body.nav-ultrawide.navigating,
  body.nav-ultrawide #navCol {
    --nav-panel-w: clamp(280px, 19vw, 400px);
  }
  body.nav-ultrawide {
    /* Высоты мало, но кнопка остаётся нажимаемой краем глаза. */
    --nav-btn: clamp(48px, 7vh, 56px);
  }
  body.nav-ultrawide #navCol {
    display: flex; flex-direction: column; gap: var(--nav-gap);
    position: fixed; z-index: 1400;
    left: calc(var(--nav-edge) + var(--nav-sal));
    top: calc(var(--nav-edge) + var(--nav-sat));
    width: var(--nav-panel-w);
    max-height: calc(100dvh - 2 * var(--nav-edge));
  }
  body.nav-ultrawide #navBox,
  body.nav-ultrawide #navBar {
    position: static; left: auto; right: auto; top: auto; bottom: auto;
    transform: none; width: 100%; margin: 0; box-sizing: border-box;
  }
  body.nav-ultrawide #navBox { padding: 12px 14px; border-radius: 16px }
  body.nav-ultrawide #navBar { padding: 10px 12px; border-radius: 16px; flex-wrap: wrap; gap: 10px }
  body.nav-ultrawide #navStats { flex: 1 1 120px }
  body.nav-ultrawide #navTop { gap: 12px }
  body.nav-ultrawide #navArrow { font-size: clamp(36px, 8vh, 48px); width: 1.15em }
  body.nav-ultrawide #navDist { font-size: clamp(28px, 6vh, 38px) }
  body.nav-ultrawide #navText { font-size: clamp(16px, 2.6vh, 20px); line-height: 1.25 }
  body.nav-ultrawide #navNext { font-size: clamp(13px, 1.9vh, 15px); margin-top: 8px; padding-top: 8px }
  body.nav-ultrawide #navEta { font-size: clamp(18px, 2.6vh, 22px) }
  body.nav-ultrawide #navRest { font-size: clamp(13px, 1.9vh, 16px) }
  body.nav-ultrawide #navBar button {
    min-width: var(--nav-btn); height: var(--nav-btn);
    font-size: clamp(19px, 3vh, 23px); border-radius: 14px;
  }
  body.nav-ultrawide #navBar #navStopBtn {
    font-size: clamp(14px, 2.1vh, 17px); min-width: 100%; height: var(--nav-btn); padding: 0 16px;
  }
  body.nav-ultrawide #navCtl {
    left: auto; right: calc(var(--nav-edge) + var(--nav-sar));
    top: 50%; bottom: auto; transform: translateY(-50%);
    gap: clamp(6px, 1.4vh, 10px);
  }
  body.nav-ultrawide #navCtl button {
    width: var(--nav-btn); height: var(--nav-btn);
    border-radius: 14px; font-size: clamp(19px, 2.8vh, 24px);
  }
  body.nav-ultrawide #navCtl button svg { width: clamp(21px, 3vh, 26px); height: clamp(21px, 3vh, 26px) }
  body.nav-ultrawide #navSpeed {
    left: calc(var(--nav-edge) + var(--nav-sal));
    bottom: calc(var(--nav-edge) + var(--nav-sab));
    width: clamp(70px, 15vh, 84px); height: clamp(70px, 15vh, 84px);
  }
  body.nav-ultrawide #navSpeedV { font-size: clamp(24px, 5vh, 30px) }
  body.nav-ultrawide #navLim {
    left: calc(var(--nav-edge) + var(--nav-sal) + clamp(78px, 16vh, 92px));
    bottom: calc(var(--nav-edge) + var(--nav-sab));
  }
  body.nav-ultrawide #navHaz {
    left: calc(var(--nav-edge) + var(--nav-sal));
    bottom: calc(var(--nav-edge) + var(--nav-sab) + clamp(80px, 17vh, 96px));
  }
  body.nav-ultrawide #navTgt {
    left: auto; right: calc(var(--nav-edge) + var(--nav-sar) + clamp(56px, 7vh, 70px));
    transform: none; width: min(520px, 36vw);
    bottom: calc(var(--nav-edge) + var(--nav-sab));
  }
  body.nav-ultrawide #navTgt .go { height: var(--nav-btn) }
  body.nav-ultrawide #navResume { bottom: calc(var(--nav-edge) + var(--nav-sab)) }

  body.nav-ultrawide.navigating {
    height: 100dvh; overflow: hidden; overscroll-behavior: none;
  }

  /* На широком экране «Завершить» уже есть в панели, а тема/язык на ходу не
     нужны: рельс остаётся компас/зум/слои/звук. На телефоне всё как было. */
  body.nav-wide #navCtl #navCloseBtn, body.nav-wide #navCtl #navThemeBtn,
  body.nav-wide #navCtl #navLangBtn,
  body.nav-ultrawide #navCtl #navCloseBtn, body.nav-ultrawide #navCtl #navThemeBtn,
  body.nav-ultrawide #navCtl #navLangBtn { display: none }

  /* Зум в рельсе нужен только там, где рельс есть; на телефоне его нет,
     чтобы эталонный портрет остался байт-в-байт по раскладке. */
  @media (max-width: 699.98px) {
    #navCtl #navZoomIn, #navCtl #navZoomOut { display: none }
  }

  /* ================= АВТО / ГОЛОВНОЕ УСТРОЙСТВО (nav-ui-car) =================
     Кнопка — от 56px, зазор 12px, манёвр 22–28px, ETA 24px, высокий контраст.
     Панель всегда колонкой слева (как на десктопе), кроме вертикального
     экрана: у поворотного BYD портрет остаётся вертикальным. */
  body.nav-ui-car {
    --nav-btn: 56px;
    --nav-gap: 12px;
    --nav-maneuver: clamp(22px, 3.1vh, 28px);
    --nav-eta: clamp(22px, 3.4vh, 28px);
    --nav-rest: clamp(16px, 2.2vh, 19px);
    --nav-nt: clamp(16px, 2.2vh, 19px);
  }
  body.nav-ui-car:not(.nav-portrait):not(.nav-compact) #navCol {
    display: flex; flex-direction: column; gap: 12px;
    position: fixed; z-index: 1400;
    left: calc(var(--nav-edge) + var(--nav-sal));
    top: calc(var(--nav-edge) + var(--nav-sat));
    width: clamp(340px, 26vw, 460px);
    max-height: calc(100dvh - 2 * var(--nav-edge));
  }
  body.nav-ui-car:not(.nav-portrait):not(.nav-compact) #navBox,
  body.nav-ui-car:not(.nav-portrait):not(.nav-compact) #navBar {
    position: static; left: auto; right: auto; top: auto; bottom: auto;
    transform: none; width: 100%; margin: 0; box-sizing: border-box;
  }
  body.nav-ui-car #navBox {
    background: #050a12; border: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 10px 34px rgba(0, 0, 0, .7);
  }
  body.nav-ui-car #navText { font-size: var(--nav-maneuver); color: #eef5ff; font-weight: 600 }
  body.nav-ui-car #navNext { font-size: var(--nav-nt); color: #b9cde3 }
  body.nav-ui-car #navEta { font-size: var(--nav-eta) }
  body.nav-ui-car #navRest { font-size: var(--nav-rest) }
  body.nav-ui-car #navDist { font-size: clamp(38px, 6vh, 54px) }
  body.nav-ui-car #navArrow { font-size: clamp(48px, 8vh, 64px) }
  body.nav-ui-car #navBar { flex-wrap: wrap; gap: 12px }
  body.nav-ui-car #navStats { flex: 1 1 140px }
  body.nav-ui-car #navBar button { min-width: 56px; height: 56px; font-size: 24px }
  body.nav-ui-car #navBar #navStopBtn {
    min-width: 100%; height: 56px; font-size: clamp(16px, 2.2vh, 19px);
  }
  body.nav-ui-car #navCtl { gap: 12px }
  body.nav-ui-car #navCtl button { width: 56px; height: 56px; border-radius: 16px; font-size: 24px }
  body.nav-ui-car #navCtl button svg { width: 28px; height: 28px }
  body.nav-ui-car #navSpeed { width: 88px; height: 88px }
  body.nav-ui-car #navSpeedV { font-size: 32px }
  body.nav-ui-car #navSpeedU { font-size: 12px }
  /* Под авто спидо­метр крупнее (88px), поэтому знак лимита и «опасность»
     сдвигаем по фактическому размеру, а не по прежним 84px. */
  body.nav-ui-car:not(.nav-portrait):not(.nav-compact) #navSpeed {
    left: calc(var(--nav-edge) + var(--nav-sal));
    bottom: calc(var(--nav-edge) + var(--nav-sab));
  }
  body.nav-ui-car:not(.nav-portrait):not(.nav-compact) #navLim {
    left: calc(var(--nav-edge) + var(--nav-sal) + 96px);
    bottom: calc(var(--nav-edge) + var(--nav-sab));
  }
  body.nav-ui-car:not(.nav-portrait):not(.nav-compact) #navHaz {
    left: calc(var(--nav-edge) + var(--nav-sal));
    bottom: calc(var(--nav-edge) + var(--nav-sab) + 100px);
  }
  body.nav-ui-car #navTgt {
    left: auto; right: calc(var(--nav-edge) + var(--nav-sar) + 84px);
    transform: none; width: min(560px, 38vw);
  }
  body.nav-ui-car #navTgt .go, body.nav-ui-car #navTgt .no { height: 56px }
  body.nav-ui-car.navigating { height: 100dvh; overflow: hidden; overscroll-behavior: none }

  /* В машине шапка сайта — лишние 58px и лишние касания: на ходу нужна карта,
     а не меню «Отели/Такси». Ведение занимает весь экран; при выходе шапка
     возвращается (правило действует только пока body.navigating). На телефоне
     (<700px) шапку не трогаем — эталонный портрет остаётся как был. */
  @media (min-width: 700px) {
    body.navigating .nx-hdr, body.navigating .nx-cats { display: none !important }
    body.navigating { --nx-hdr-h: 0px }
  }

  /* Вертикальный экран авто (поворотный BYD): панель сверху, но крупнее. */
  body.nav-ui-car.nav-portrait #navBox,
  body.nav-ui-car.nav-compact #navBox {
    width: min(700px, calc(100vw - 2 * var(--nav-edge)));
  }
  body.nav-ui-car.nav-portrait #navBar,
  body.nav-ui-car.nav-compact #navBar {
    width: min(700px, calc(100vw - 2 * var(--nav-edge)));
  }

  /* Карточка места (клик по метке) и «вернуться к маршруту» не должны
     попадать под рельс/плашку ни в одной широкой раскладке. */
  body.nav-wide:has(#navTgt.show) #navCtl,
  body.nav-ultrawide:has(#navTgt.show) #navCtl,
  body.nav-portrait:has(#navTgt.show) #navCtl,
  body.nav-compact:has(#navTgt.show) #navCtl,
  body.nav-ui-car:has(#navTgt.show) #navCtl { bottom: auto }
}

/* Меньше анимаций — по системной настройке (магнитолы и старые WebView любят
   тормозить на пульсациях; водителю мигание только мешает). */
@media (prefers-reduced-motion: reduce) {
  #navBox, #navBar, #navTgt, #navCtl, #navSpeed, #navLim, #navSpeedV,
  #navCtl button, #navBar button, #navArrow, #navCompassBtn svg,
  .nav-puck-i { animation: none !important; transition: none !important }
}
