* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* position:fixed + overflow:hidden — iOS Safari игнорирует user-scalable=no
   и умеет зумить/скроллить саму страницу пинчем по панелям; тогда весь
   интерфейс "уезжает" за экран (кнопки поиска/геолокации пропадают).
   Фиксируем страницу намертво: зум и скролл остаются только у самой карты. */
html, body {
  margin: 0;
  padding: 0;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#map { position: absolute; inset: 0; }

#top-bar {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
  pointer-events: none;
}
#app-title {
  background: rgba(20, 22, 30, 0.85);
  color: #fff;
  padding: 8px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  pointer-events: auto;
}
#locate-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 22, 30, 0.85);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  pointer-events: auto;
}
#locate-btn.active { background: #2ecc71; }

#top-bar-buttons { display: flex; gap: 8px; pointer-events: auto; }
#route-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 22, 30, 0.85);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
#route-btn.active { background: #3498db; }

#search-panel {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 12px;
  right: 12px;
  z-index: 8;
  background: rgba(20, 22, 30, 0.95);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  overflow: hidden;
}
#search-panel.hidden { display: none; }
#search-input-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
#search-input {
  flex: 1;
  border: none;
  outline: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 15px;
  padding: 10px 14px;
  border-radius: 10px;
  -webkit-appearance: none;
}
#search-input::placeholder { color: rgba(255,255,255,0.45); }
#search-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}
#search-results { max-height: 55vh; overflow-y: auto; }
.search-section {
  padding: 6px 14px 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.4);
  font-weight: 700;
}
.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.search-row:active { background: rgba(255,255,255,0.08); }
.search-row-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  color: #fff;
  font-weight: 700;
}
.search-row-body { flex: 1; min-width: 0; }
.search-row-title {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-row-sub {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-empty { padding: 14px; color: rgba(255,255,255,0.5); font-size: 13px; text-align: center; }

#route-hint {
  position: absolute;
  top: calc(env(safe-area-inset-top, 12px) + 56px);
  left: 12px;
  right: 12px;
  z-index: 5;
  background: rgba(52, 152, 219, 0.95);
  color: #fff;
  text-align: center;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  pointer-events: none;
}
#route-hint.hidden { display: none; }

#legend {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 16px);
  left: 12px;
  right: 12px;
  background: rgba(20, 22, 30, 0.92);
  color: #fff;
  border-radius: 14px;
  z-index: 5;
  max-height: 60vh;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}
#legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
}
#legend-list {
  padding: 0 12px 12px;
  overflow-y: auto;
  max-height: calc(60vh - 44px);
  display: none;
}
#legend.open #legend-list { display: block; }
#legend.open #legend-toggle { transform: rotate(180deg); }
#legend-toggle { transition: transform 0.2s; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.legend-item:first-child { border-top: none; }
.legend-swatch {
  width: 22px;
  height: 5px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-text { flex: 1; line-height: 1.3; }
.legend-operator { opacity: 0.6; font-size: 11px; }

#stop-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
  z-index: 10;
  padding: 6px 18px 24px;
  transform: translateY(0);
  transition: transform 0.25s ease;
}
#stop-sheet.hidden { transform: translateY(110%); }
#stop-sheet-handle {
  width: 40px;
  height: 4px;
  background: #ccc;
  border-radius: 2px;
  margin: 8px auto 12px;
}
#stop-sheet-title { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
#stop-sheet-routes { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
.route-chip {
  padding: 6px 12px;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.stop-route-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid #f0f0f0;
}
.stop-route-row:first-child { border-top: none; }
.stop-route-info { flex: 1; min-width: 0; }
.stop-route-to {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stop-route-sub { font-size: 12px; color: #888; margin-top: 2px; }
.stop-route-sub-muted { color: #c0392b; }

#itinerary-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
  z-index: 11;
  padding: 6px 18px 24px;
  max-height: 62vh;
  overflow-y: auto;
  transform: translateY(0);
  transition: transform 0.25s ease;
}
#itinerary-sheet.hidden { transform: translateY(110%); }
#itinerary-handle {
  width: 40px;
  height: 4px;
  background: #ccc;
  border-radius: 2px;
  margin: 8px auto 12px;
}
#itinerary-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#itinerary-total { font-weight: 700; font-size: 18px; }
#itinerary-actions { display: flex; gap: 8px; }
#itinerary-actions button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #f1f2f4;
  font-size: 15px;
}

#itinerary-alts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.itinerary-alt {
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 12px;
  background: #fafafa;
  color: #333;
}
.itinerary-alt.selected { background: #2c3e50; color: #fff; border-color: #2c3e50; }

#itinerary-steps { display: flex; flex-direction: column; gap: 10px; }
.itin-step { display: flex; gap: 10px; align-items: flex-start; }
.itin-step-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #fff;
  background: #95a5a6;
}
.itin-step-body { flex: 1; padding-top: 4px; }
.itin-step-title { font-weight: 600; font-size: 14px; }
.itin-step-sub { font-size: 12px; color: #777; margin-top: 2px; }

#route-detail-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
  z-index: 11;
  padding: 6px 18px 24px;
  max-height: 62vh;
  overflow-y: auto;
  transform: translateY(0);
  transition: transform 0.25s ease;
}
#route-detail-sheet.hidden { transform: translateY(110%); }
#route-detail-handle {
  width: 40px;
  height: 4px;
  background: #ccc;
  border-radius: 2px;
  margin: 8px auto 12px;
}
#route-detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
#route-detail-badge {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 12px;
  flex-shrink: 0;
}
#route-detail-fromto { flex: 1; font-size: 14px; font-weight: 600; color: #222; line-height: 1.3; }
#route-detail-next { font-size: 13px; font-weight: 600; margin: 2px 0 4px; }
#route-detail-next.route-detail-next-active { color: #16a085; }
#route-detail-next.route-detail-next-before,
#route-detail-next.route-detail-next-after { color: #c0392b; }
#route-detail-meta { font-size: 12px; color: #777; margin: 2px 0 8px; }
#route-detail-meta span { margin-right: 10px; }
#route-detail-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f1f2f4;
  font-size: 14px;
  flex-shrink: 0;
}

#route-detail-directions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.route-detail-dir {
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 12px;
  background: #fafafa;
  color: #333;
}
.route-detail-dir.selected { background: #2c3e50; color: #fff; border-color: #2c3e50; }

#route-detail-stops-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid #eee;
  font-size: 13px;
  color: #555;
  font-weight: 600;
}
#route-detail-stops-arrow { transition: transform 0.2s; }
#route-detail-sheet.expanded #route-detail-stops-arrow { transform: rotate(180deg); }
#route-detail-stops-list { display: none; padding-bottom: 6px; }
#route-detail-sheet.expanded #route-detail-stops-list { display: block; }
.route-detail-stop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  border-top: 1px solid #f4f4f4;
}
.route-detail-stop-row:first-child { border-top: none; }
.route-detail-stop-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f1f2f4;
  color: #555;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* --- Панель выбранного места с кнопкой "Построить маршрут" --- */
#dest-panel {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 7;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 -2px 20px rgba(0,0,0,0.25);
  padding: 14px 16px;
}
#dest-panel.hidden { display: none; }
#dest-panel-title {
  font-size: 15px;
  font-weight: 700;
  color: #222;
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#dest-panel-row { display: flex; gap: 10px; }
#dest-panel-go {
  flex: 1;
  border: none;
  border-radius: 12px;
  background: #3498db;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 12px;
}
#dest-panel-go:disabled { background: #95a5a6; }
#dest-panel-close {
  width: 44px;
  border-radius: 12px;
  border: none;
  background: #f1f2f4;
  font-size: 15px;
  flex-shrink: 0;
}

/* --- Кнопка и полноэкранная карточка "покажи водителю" --- */
.driver-card-btn {
  margin-top: 6px;
  border: 1px solid #2c3e50;
  border-radius: 12px;
  background: #fff;
  color: #2c3e50;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
}
.driver-card-btn:active { background: #2c3e50; color: #fff; }

#driver-card {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 20px;
  gap: 14px;
}
#driver-card.hidden { display: none; }
#driver-card-badge {
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  padding: 8px 20px;
  border-radius: 14px;
}
#driver-card-phrase {
  font-size: 24px;
  font-weight: 700;
  color: #c0392b;
}
#driver-card-name {
  font-size: clamp(34px, 9vw, 58px);
  font-weight: 800;
  color: #111;
  line-height: 1.15;
  overflow-wrap: break-word;
  max-width: 100%;
}
#driver-card-near {
  font-size: 22px;
  font-weight: 600;
  color: #333;
}
#driver-card-near:empty { display: none; }
#driver-card-fare {
  font-size: 22px;
  font-weight: 700;
  color: #16a085;
  margin-top: 8px;
}
#driver-card-translations {
  margin-top: 18px;
  font-size: 12px;
  color: #888;
  line-height: 1.5;
  max-width: 420px;
}
#driver-card-close-hint {
  position: absolute;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  font-size: 11px;
  color: #bbb;
}

.maplibregl-ctrl-attrib { font-size: 10px; }
