/* ============================================================
   Навигация для фур — дизайн по макету Claude Design
   Палитра: графит #333, оранжевый акцент #F26522, CTA #C6410A.
   Слои поверх карты: «матовое стекло», мягкие тени.
   ============================================================ */

:root {
  /* Палитра из макета */
  --ink: #333333;            /* основной текст */
  --ink-2: #5c6470;          /* вторичный текст */
  --ink-3: #9aa1ab;          /* подписи, плейсхолдеры */
  --accent: #F26522;         /* акцент: ссылки, выделение, маркеры */
  --cta: #C6410A;            /* кнопки действия и активные чипы */
  --accent-ink: #ffffff;
  --accent-soft: rgba(242, 101, 34, 0.1);
  --ok: #119c50;
  --bad: #d92d20;
  --warn: #8a5900;

  /* Поверхности */
  --glass: rgba(255, 255, 255, 0.86);
  --glass-blur: saturate(1.4) blur(16px);
  --surface: #ffffff;
  --field: #f2f4f7;
  --line: rgba(25, 28, 32, 0.08);

  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-2: 0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-3: 0 20px 40px -8px rgba(16, 24, 40, 0.18), 0 8px 16px -6px rgba(16, 24, 40, 0.08);
  --glow-accent: 0 8px 20px -6px rgba(242, 101, 34, 0.55);

  --r-s: 10px;
  --r-m: 14px;
  --r-l: 18px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #e9edf2;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: var(--font); }

a { color: var(--accent); text-decoration: none; }

/* =============== Рамка «телефона» ===============
   Внутри Telegram и на телефонах — во весь экран. На широких экранах —
   колонка 390px по центру: transform создаёт containing block, поэтому все
   fixed-элементы приложения позиционируются внутри рамки. */
.app-frame {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #e9edf2;
}

@media (min-width: 700px) {
  body { background: #dde2e9; }
  .app-frame {
    inset: auto;
    left: 50%;
    top: 24px;
    transform: translateX(-50%);
    width: 390px;
    height: calc(100vh - 48px);
    max-height: 820px;
    border-radius: 22px;
    box-shadow: var(--shadow-3), 0 0 0 1px rgba(25, 28, 32, 0.08);
  }
}

#map { position: fixed; inset: 0; }

/* ================= Шапка (вне Telegram — превью его хрома) ================= */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(50px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 8px 0;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}

.app-header-close {
  width: 92px;
  border: none;
  background: none;
  text-align: left;
  font-size: 17px;
  color: var(--accent);
  cursor: pointer;
  padding: 12px 8px;
}

.app-header-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.app-header-more {
  width: 92px;
  display: flex;
  justify-content: flex-end;
  padding-right: 4px;
  color: transparent; /* прячем текстовый узел, рисуем кружок */
  cursor: pointer;
}
.app-header-more::after {
  content: "⋯";
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--field);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  letter-spacing: 1px;
}

/* Когда шапка видна — сдвигаем верхние слои */
body.has-header .search-card { top: calc(env(safe-area-inset-top, 0px) + 60px); }
body.has-header .chips-bar { top: calc(env(safe-area-inset-top, 0px) + 192px); }

/* ============== Затемнение карты при фокусе в поиске ============== */

.search-dim {
  position: fixed;
  inset: 0;
  z-index: 16; /* над картой и чипами, под карточкой поиска */
  background: rgba(16, 24, 40, 0.12);
  animation: fade 0.18s ease;
}
body.has-header .search-dim { top: calc(env(safe-area-inset-top, 0px) + 48px); }

/* ============================== Поиск ============================== */

.search-card {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  right: 12px;
  z-index: 20;
  max-width: 560px;
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}

.search-rows { padding: 2px 14px; }

.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 58px;
}

.field-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.field-label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
}

.search-row input {
  border: none;
  outline: none;
  font-size: 16px;
  font-weight: 450;
  background: transparent;
  color: var(--ink);
  min-width: 0;
  width: 100%;
  padding: 0;
}

.search-row input::placeholder { color: #8a919b; font-weight: 400; }

.search-divider {
  height: 1px;
  background: var(--line);
  margin-left: 24px;
}

/* Точки маршрута: старт — зелёное кольцо, финиш — красная точка */
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-a { border: 3px solid var(--ok); background: transparent; }
.dot-b { background: var(--bad); }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--field); color: var(--ink-2); }
.icon-btn:active { background: var(--line); }
.icon-btn-filled { background: var(--field); }

.suggestions {
  border-top: 1px solid var(--line);
  max-height: 42vh;
  overflow-y: auto;
  background: var(--surface);
}

.suggestion {
  padding: 13px 16px 13px 40px;
  font-size: 15px;
  line-height: 1.35;
  cursor: pointer;
  color: var(--ink-2);
  position: relative;
  transition: background 0.12s ease;
}
.suggestion::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
}
.suggestion + .suggestion { border-top: 1px solid var(--line); }
.suggestion:hover { background: #f7f9fc; }
.suggestion:active { background: var(--accent-soft); }
/* Совпавшая с запросом часть — жирнее и темнее (экран 06) */
.suggestion b { color: var(--ink); font-weight: 550; }

/* Заголовок «Недавние» и строка «Вставить из буфера» */
.suggestions-header {
  padding: 10px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.suggestion-action {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 550;
  color: var(--accent);
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.suggestion-action:active { background: var(--accent-soft); }

.input-clear { width: 28px; height: 28px; }

/* ============================== Чипы ============================== */

.chips-bar {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 142px);
  left: 0;
  right: 0;
  z-index: 15;
  display: flex;
  gap: 8px;
  padding: 4px 12px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips-bar::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  color: var(--ink);
  border-radius: 999px;
  padding: 0 14px;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 550;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
    transform 0.1s ease;
}
.chip svg { flex-shrink: 0; }
.chip:active { transform: scale(0.97); }

.chip.active {
  background: var(--cta);
  border-color: var(--cta);
  color: var(--accent-ink);
  box-shadow: 0 4px 12px -2px rgba(242, 101, 34, 0.45);
}

.chip-vehicle {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* Спиннер на чипе, пока грузятся его точки */
.chip.loading::after {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-left: 2px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: chip-spin 0.7s linear infinite;
}

@keyframes chip-spin {
  to { transform: rotate(360deg); }
}

/* ===================== Низ: сводка и кнопка ===================== */

/* Кнопка во всю ширину, вплотную к низу — как в Mini App */
.bottom-bar {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
}

.bottom-bar .primary-btn {
  border-radius: 0;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: none;
}

.primary-btn {
  width: 100%;
  border: none;
  background: var(--cta);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  height: 56px;
  border-radius: var(--r-m);
  box-shadow: var(--glow-accent), var(--shadow-1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.12s ease, filter 0.15s ease;
}
.primary-btn:hover:not(:disabled) { filter: brightness(1.07); }
.primary-btn:active:not(:disabled) { transform: scale(0.99); }
.primary-btn:disabled {
  background: #c6ccd4;
  box-shadow: none;
  cursor: default;
}

/* Скруглённая версия — внутри модалок и панелей */
.primary-btn-rounded { border-radius: var(--r-m) !important; height: 56px !important; padding-bottom: 0 !important; }

/* Спиннер на кнопке при построении маршрута */
.primary-btn.loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: chip-spin 0.7s linear infinite;
}

.route-summary {
  position: fixed;
  left: 12px;
  right: 12px;
  z-index: 19;
  max-width: 560px;
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-2);
  padding: 14px 18px 12px;
  animation: rise 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.route-summary { bottom: calc(env(safe-area-inset-bottom, 0px) + 64px); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.summary-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: var(--field);
  color: var(--ink-2);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}
.summary-close:hover { background: var(--line); }

.summary-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.summary-time {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.summary-distance {
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* Варианты маршрута — сегмент-контрол (И2-04b) */
.summary-variants {
  display: flex;
  background: var(--field);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  margin-top: 12px;
}

.variant-chip {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.variant-chip.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

/* Статусы пригодности — цветные пилюли */
.summary-status {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.summary-status .st {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
}
.summary-status .st svg { flex-shrink: 0; }
.summary-status .st-ok { background: rgba(17, 156, 80, 0.1); color: var(--ok); }
.summary-status .st-warn { background: rgba(138, 89, 0, 0.1); color: var(--warn); }
.summary-status .st-info { background: var(--field); color: var(--ink-2); font-weight: 500; }

/* Кнопка «Маршрут по этапам» */
.steps-btn {
  margin-top: 12px;
  width: 100%;
  height: 48px;
  border: 1.5px solid rgba(25, 28, 32, 0.15);
  background: transparent;
  border-radius: var(--r-m);
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.steps-btn:active { background: var(--field); }

/* Список этапов */
.steps-list {
  max-height: 62vh;
  overflow-y: auto;
  margin: 0 -4px;
}

.step-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 12px 4px;
  font-size: 14.5px;
  line-height: 1.4;
}
.step-row + .step-row { border-top: 1px solid var(--line); }

.step-dist {
  flex-shrink: 0;
  width: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.step-text { color: var(--ink); }

.summary-extra {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 550;
  color: var(--warn);
}

.summary-note { margin-top: 6px; font-size: 12px; color: var(--ink-2); line-height: 1.4; }

.summary-disclaimer {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.4;
}
.summary-disclaimer svg { vertical-align: -1px; margin-right: 4px; }

/* Скелетон сводки (экран 08) */
.skeleton-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
}

.sk {
  display: block;
  border-radius: 6px;
  background: rgba(25, 28, 32, 0.08);
  animation: sk-pulse 1.2s ease-in-out infinite;
}
.sk-1 { width: 148px; height: 24px; }
.sk-2 { width: 210px; height: 13px; background: rgba(25, 28, 32, 0.06); }
.sk-3 { width: 100%; height: 11px; background: rgba(25, 28, 32, 0.05); }

@keyframes sk-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Маршрут не найден */
.error-card { padding: 16px 18px 14px; }

.error-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.error-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(217, 45, 32, 0.1);
  color: var(--bad);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.error-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--bad);
}

.error-text {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.45;
}

.error-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 13.5px;
  font-weight: 600;
}

/* ============================ Модалка ============================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16, 24, 40, 0.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.2s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  border-radius: var(--r-l) var(--r-l) 0 0;
  padding: 20px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  max-height: 85vh;
  overflow-y: auto;
  animation: rise 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}


.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 8px;
}

.field-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
}

.field-grid input, .field-grid select {
  border: 1.5px solid transparent;
  border-radius: var(--r-s);
  padding: 10px 11px;
  font-size: 17px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--field);
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
  appearance: none;
}
.field-grid input:focus, .field-grid select:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 450;
  padding: 12px 2px;
  cursor: pointer;
}
.check-row + .check-row { border-top: 1px solid var(--line); }
.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

#vehicleSaveBtn { margin-top: 14px; }

/* ============================= Прочее ============================= */

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
  z-index: 50;
  background: rgba(25, 28, 32, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  max-width: 88vw;
  text-align: center;
  box-shadow: var(--shadow-2);
  animation: rise 0.22s ease;
}

.maplibregl-popup-content {
  font-family: var(--font);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-3);
  padding: 8px;
}

/* Маркеры старта и финиша (кастомные элементы) */
.route-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.3);
}
.route-marker-start { background: #ffffff; border: 4px solid var(--ok); }
.route-marker-end { background: var(--bad); border: 3px solid #ffffff; }

/* Контролы карты и копирайт — над нижней кнопкой */
.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 68px);
}

/* Штатные кнопки MapLibre (зум, геолокатор) скрыты — их функции выполняют
   собственные кнопки приложения. Атрибуция (ⓘ) остаётся: лицензия OSM/Carto */
.maplibregl-ctrl-group { display: none !important; }

/* Синяя точка текущей позиции */
.user-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1c93ff;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 6px rgba(28, 147, 255, 0.22), 0 1px 3px rgba(16, 24, 40, 0.3);
}
:root[data-theme="night"] .user-dot { border-color: #1e2126; }

/* ======================= Карточка объекта ======================= */

.poi-panel {
  position: fixed;
  z-index: 35;
  background: var(--surface);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Шторка снизу (экран 10) */
.poi-panel {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 62vh;
  border-radius: var(--r-l) var(--r-l) 0 0;
  box-shadow: 0 -20px 40px -8px rgba(16, 24, 40, 0.18);
  animation: rise 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.poi-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform 0.12s ease;
}
.poi-panel-close:active { transform: scale(0.92); }

.poi-panel-photo {
  height: 128px;
  flex-shrink: 0;
  background: #eef1f5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  position: relative;
}

.poi-panel-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poi-panel-body {
  padding: 10px 18px 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* иначе flex не даёт телу сжиматься и появляться скроллу */
}

.poi-panel-actions {
  padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 14px);
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* Содержимое карточки */
.poi-popup { font-size: 14px; line-height: 1.45; color: var(--ink); }

.poi-popup .poi-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin-bottom: 1px;
}

.poi-popup .poi-tag {
  color: var(--ink-2);
  font-size: 13.5px;
  margin-top: 7px;
  display: block;
}

.poi-popup .poi-open,
.poi-popup .poi-closed {
  font-size: 12.5px;
  font-weight: 650;
  margin-top: 7px;
}
.poi-popup .poi-open { color: var(--ok); }
.poi-popup .poi-closed { color: var(--bad); }

.poi-popup .poi-amenities {
  color: var(--ink);
  background: var(--field);
  border-radius: var(--r-s);
  padding: 8px 11px;
  font-size: 12.5px;
  line-height: 1.6;
  display: block;
  margin-top: 9px;
}

.poi-popup .poi-verified {
  color: var(--ok);
  font-weight: 600;
  font-size: 12px;
  margin-top: 10px;
}

.poi-popup a { color: var(--accent); text-decoration: none; font-weight: 500; }

.poi-context-title {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.poi-hours { color: var(--ink-3); font-size: 12px; }
.poi-context-loading { color: var(--ink-3); }

/* ==================== Онбординг (экраны 01–03) ==================== */

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
body.has-header .onboarding { top: calc(env(safe-area-inset-top, 0px) + 48px); z-index: 39; }

.ob-slide {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 0 40px;
  text-align: center;
}

.ob-icon {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.ob-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.ob-text {
  font-size: 14.5px;
  color: var(--ink-2);
  line-height: 1.5;
  max-width: 290px;
}

.ob-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding-bottom: 22px;
}

.ob-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(25, 28, 32, 0.15);
  transition: width 0.25s ease, background 0.25s ease;
}
.ob-dot.active {
  width: 20px;
  border-radius: 999px;
  background: var(--accent);
}

.ob-btn {
  border-radius: 0 !important;
  height: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
  padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  box-shadow: none !important;
  flex-shrink: 0;
}

/* ======= Подсказка компактного режима Telegram (экран 04) ======= */

.expand-hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 62px);
  z-index: 45;
  background: var(--ink);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  white-space: nowrap;
  animation: rise 0.25s ease;
}

/* ==================== Профили фуры (И2-03a) ==================== */

.profile-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 14px;
  padding-bottom: 2px;
}
.profile-chips::-webkit-scrollbar { display: none; }

.profile-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  border: 1px solid rgba(25, 28, 32, 0.12);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0 6px 0 14px;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.profile-chip.active {
  background: var(--cta);
  border-color: var(--cta);
  color: #ffffff;
  font-weight: 600;
}

.profile-chip .pencil {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(25, 28, 32, 0.06);
  color: inherit;
}
.profile-chip.active .pencil { background: rgba(255, 255, 255, 0.2); }

.profile-chip-add {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 38px;
  border: 1px dashed rgba(25, 28, 32, 0.25);
  background: transparent;
  color: var(--accent);
  border-radius: 999px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.profile-name {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.profile-name input {
  border: 1.5px solid transparent;
  border-radius: var(--r-s);
  padding: 10px 11px;
  font-size: 16px;
  font-family: var(--font);
  color: var(--ink);
  background: var(--field);
  outline: none;
}
.profile-name input:focus { border-color: var(--accent); background: var(--surface); }

.form-group-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 14px 0 8px;
}

.field-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-warn {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  color: var(--warn);
  font-size: 13px;
  font-weight: 550;
}

.profile-delete {
  margin-top: 10px;
  width: 100%;
  border: none;
  background: none;
  color: var(--bad);
  font-size: 14.5px;
  font-weight: 600;
  padding: 10px;
  cursor: pointer;
}

/* ==================== Экран «Мои маршруты» (И2-05) ==================== */

.routes-screen {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: #f6f7f9;
  display: flex;
  flex-direction: column;
}

.routes-header {
  height: calc(50px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 8px 0;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.routes-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px calc(env(safe-area-inset-bottom, 0px) + 20px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rs-card {
  background: var(--surface);
  border-radius: var(--r-l);
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.08);
  padding: 16px;
}

.rs-continue-head { display: flex; align-items: center; gap: 12px; }

.rs-continue-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rs-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.rs-sub { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.rs-continue-btn {
  margin-top: 12px;
  width: 100%;
  height: 48px;
  border: none;
  background: var(--cta);
  color: #ffffff;
  font-size: 16px;
  font-weight: 650;
  border-radius: 12px;
  cursor: pointer;
}

.rs-section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 4px 8px;
}

.rs-list {
  background: var(--surface);
  border-radius: var(--r-l);
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.08);
  overflow: hidden;
}

.rs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
}
.rs-row + .rs-row { border-top: 1px solid rgba(25, 28, 32, 0.06); }
.rs-row:active { background: var(--accent-soft); }

.rs-row-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--field);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rs-row-main { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rs-row-title { font-size: 16px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-row-sub { font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-row-chevron { color: var(--ink-3); font-size: 14px; }
.rs-row-remove { border: none; background: none; color: var(--ink-3); padding: 6px; cursor: pointer; }

.rs-add-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  color: var(--accent);
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
}

.rs-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 40px 44px;
}
.rs-empty-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rs-empty-title { font-size: 21px; font-weight: 750; color: var(--ink); }
.rs-empty-text { font-size: 15.5px; color: var(--ink-2); line-height: 1.5; max-width: 280px; }

/* Переключатель темы */
.theme-switch {
  display: flex;
  background: rgba(25, 28, 32, 0.06);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}
.theme-switch button {
  flex: 1;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
}
.theme-switch button.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

/* ==================== Активная навигация (И2-06) ==================== */

body.nav-mode .search-card,
body.nav-mode .chips-bar,
body.nav-mode .bottom-bar,
body.nav-mode .route-summary,
body.nav-mode .error-card { display: none !important; }

.nav-card {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  right: 12px;
  z-index: 25;
  background: var(--nav-card, #333333);
  border-radius: var(--r-l);
  box-shadow: 0 8px 20px -6px rgba(16, 24, 40, 0.4);
  padding: 16px;
}
body.has-header .nav-card { top: calc(env(safe-area-inset-top, 0px) + 62px); }

.nav-main { display: flex; align-items: center; gap: 14px; }
.nav-arrow { color: #ffffff; flex-shrink: 0; display: inline-flex; }
.nav-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.nav-dist {
  font-size: 30px;
  font-weight: 750;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.nav-text { font-size: 18px; font-weight: 550; color: #e8eaed; line-height: 1.3; }

.nav-next {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 14.5px;
  color: #b8bec9;
}

/* Кнопки навигации прижаты к нижней панели, а не по центру экрана */
.nav-side {
  position: fixed;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 128px);
  z-index: 24;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Чипы выбора POI в шторке */
.poi-sheet-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 6px;
}

.sheet-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  border: 1px solid rgba(25, 28, 32, 0.12);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sheet-chip.active {
  background: var(--cta);
  border-color: var(--cta);
  color: #ffffff;
}
:root[data-theme="night"] .sheet-chip { border-color: rgba(255, 255, 255, 0.12); }

.nav-round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.18);
  cursor: pointer;
}
.nav-round.active { background: var(--cta); color: #ffffff; }

.nav-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  background: var(--surface);
  box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.1);
  padding: 14px 18px calc(env(safe-area-inset-bottom, 0px) + 14px);
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-eta-col { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nav-eta { font-size: 23px; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; }
.nav-left { font-size: 15px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.nav-finish {
  height: 46px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  background: rgba(217, 45, 32, 0.1);
  color: var(--bad);
  font-size: 15.5px;
  font-weight: 650;
  cursor: pointer;
}

/* Стрелка позиции пользователя */
.nav-user-arrow {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--cta);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 12px -2px rgba(242, 101, 34, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

/* ==================== Баннеры состояний (И2-07) ==================== */

.state-banner {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 190px);
  left: 12px;
  right: 12px;
  z-index: 45;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-2);
  padding: 14px 16px;
  animation: rise 0.25s ease;
}
body.nav-mode .state-banner { top: calc(env(safe-area-inset-top, 0px) + 190px); }

.state-head { display: flex; align-items: center; gap: 10px; }

.state-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(138, 89, 0, 0.12);
  color: var(--warn);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.state-title { font-size: 16.5px; font-weight: 700; color: var(--ink); }
.state-text { margin-top: 8px; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; }

.state-retry {
  margin-top: 11px;
  height: 42px;
  border: 1.5px solid rgba(25, 28, 32, 0.15);
  background: transparent;
  border-radius: 12px;
  padding: 0 18px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ==================== Ночная тема (И2-08) ==================== */

:root[data-theme="night"] {
  --ink: #e8eaed;
  --ink-2: #9aa1ab;
  --ink-3: #7d838c;
  --accent: #E05A1C;
  --accent-soft: rgba(224, 90, 28, 0.14);
  --ok: #4ec27f;
  --bad: #f07067;
  --warn: #e5a54b;
  --glass: rgba(33, 36, 41, 0.92);
  --surface: #212429;
  --field: #2a2e34;
  --line: rgba(255, 255, 255, 0.08);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 20px 40px -8px rgba(0, 0, 0, 0.55);
  --glow-accent: 0 8px 20px -6px rgba(224, 90, 28, 0.5);
  --nav-card: #2a2d33;
}

:root[data-theme="night"] body { background: #14161a; }
:root[data-theme="night"] .app-frame { background: #1e2126; }
:root[data-theme="night"] .app-header,
:root[data-theme="night"] .routes-header { background: #1c1e22; }
:root[data-theme="night"] .routes-screen { background: #1a1c20; }
:root[data-theme="night"] .search-card,
:root[data-theme="night"] .route-summary,
:root[data-theme="night"] .chip,
:root[data-theme="night"] .state-banner { border-color: rgba(255, 255, 255, 0.08); }
:root[data-theme="night"] .search-row input::placeholder { color: #7d838c; }
:root[data-theme="night"] .suggestion:hover { background: #262a30; }
:root[data-theme="night"] .sk { background: rgba(255, 255, 255, 0.08); }
:root[data-theme="night"] .sk-2 { background: rgba(255, 255, 255, 0.06); }
:root[data-theme="night"] .sk-3 { background: rgba(255, 255, 255, 0.05); }
:root[data-theme="night"] .summary-status .st-ok { background: rgba(17, 156, 80, 0.16); }
:root[data-theme="night"] .summary-status .st-warn { background: rgba(229, 165, 75, 0.14); }
:root[data-theme="night"] .steps-btn,
:root[data-theme="night"] .state-retry { border-color: rgba(255, 255, 255, 0.15); }
:root[data-theme="night"] .maplibregl-popup-content { background: var(--surface); color: var(--ink); }
:root[data-theme="night"] .route-marker-start { background: #1e2126; }
:root[data-theme="night"] .route-marker-end { border-color: #1e2126; }
:root[data-theme="night"] .poi-panel-photo { background: #2a2e34; }
:root[data-theme="night"] .nav-user-arrow { border-color: #1e2126; }
:root[data-theme="night"] .profile-chip { border-color: rgba(255, 255, 255, 0.12); }
:root[data-theme="night"] .profile-chip .pencil { background: rgba(255, 255, 255, 0.08); }
:root[data-theme="night"] .profile-chip-add { border-color: rgba(255, 255, 255, 0.25); }
:root[data-theme="night"] .theme-switch { background: rgba(255, 255, 255, 0.06); }
:root[data-theme="night"] .state-icon { background: rgba(229, 165, 75, 0.14); }
:root[data-theme="night"] .nav-finish { background: rgba(217, 45, 32, 0.16); }
:root[data-theme="night"] .app-header-more::after { background: #2a2d33; }
