:root {
  color-scheme: light dark;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px), var(--tg-content-safe-area-inset-right, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px), var(--tg-content-safe-area-inset-left, 0px));
  --panel-bg: #fff;
  --panel-text: #222;
  --panel-muted: #777;
  --panel-border: #eee;
}
* { 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; }
button, [role="button"], .legend-item, .search-row, .stop-route-row, .route-detail-stop-row {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}
button { font: inherit; cursor: pointer; transition: transform .12s ease, filter .12s ease, background-color .2s ease; }
button:active, .legend-item:active, .stop-route-row:active { transform: scale(.96); filter: brightness(.94); }
input, #driver-card-name, #driver-card-translations { user-select: text; }

#top-bar {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: calc(var(--safe-left) + 12px);
  right: calc(var(--safe-right) + 12px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  z-index: 5;
  pointer-events: none;
}
/* Геолокация: заметная круглая кнопка-стрелка слева внизу, над свёрнутой
   легендой (44px шапка + 16px отступ); в режиме слежения — синяя, в цвет маркера */
#locate-btn {
  position: absolute;
  left: calc(var(--safe-left) + 14px);
  bottom: calc(var(--safe-bottom) + 76px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 22, 30, 0.88);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  z-index: 5;
}
#locate-btn svg { display: block; }
#locate-btn.active { background: #3498db; }

/* Маркер «я здесь»: белое кольцо с синей точкой, пульс точности и
   треугольник-указатель направления (появляется, когда известен азимут) */
.user-marker { position: relative; width: 48px; height: 48px; }
.user-marker-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(52, 152, 219, 0.3);
  animation: user-marker-pulse 2.4s ease-out infinite;
}
@keyframes user-marker-pulse {
  0% { transform: scale(0.45); opacity: 0.9; }
  70% { transform: scale(1); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}
.user-marker-heading {
  position: absolute;
  inset: 0;
  display: none;
  transition: transform 0.5s ease; /* угол копится без скачка через 0°/360° (см. app.js) */
}
.user-marker.has-heading .user-marker-heading { display: block; }
.user-marker-heading::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 11px solid #3498db;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}
.user-marker-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 21px;
  height: 21px;
  margin: -10.5px 0 0 -10.5px;
  border-radius: 50%;
  background: #3498db;
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

#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: calc(var(--safe-top) + 12px);
  left: calc(var(--safe-left) + 12px);
  right: calc(var(--safe-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 { transform-origin: top center; transition: transform .2s ease, opacity .2s ease, visibility .2s; }
#search-panel.hidden { opacity: 0; transform: translateY(-12px) scale(.98); visibility: hidden; pointer-events: 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(var(--safe-top) + 68px);
  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: calc(var(--safe-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 calc(18px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(18px + var(--safe-left));
  transform: translateY(0);
  transition: transform 0.28s cubic-bezier(.22,.8,.3,1), opacity .2s ease, visibility .28s;
  will-change: transform;
}
#stop-sheet.hidden { transform: translateY(110%); opacity: 0; visibility: hidden; pointer-events: none; }
#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; transform: translateZ(0); }
.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 calc(18px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(18px + var(--safe-left));
  max-height: 62vh;
  overflow-y: auto;
  transform: translateY(0);
  overscroll-behavior: contain;
  transition: transform 0.28s cubic-bezier(.22,.8,.3,1), opacity .2s ease, visibility .28s;
  will-change: transform;
}
#itinerary-sheet.hidden { transform: translateY(110%); opacity: 0; visibility: hidden; pointer-events: none; }
#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 calc(18px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(18px + var(--safe-left));
  max-height: 62vh;
  overflow-y: auto;
  transform: translateY(0);
  overscroll-behavior: contain;
  transition: transform 0.28s cubic-bezier(.22,.8,.3,1), opacity .2s ease, visibility .28s;
  will-change: transform;
}
#route-detail-sheet.hidden { transform: translateY(110%); opacity: 0; visibility: hidden; pointer-events: none; }
#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 + var(--safe-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; }

/* кнопка «Я в автобусе» у автобусного шага построенного маршрута */
.itin-ride-btn {
  margin-top: 6px;
  border: none;
  border-radius: 12px;
  background: #27ae60;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
}
.itin-ride-btn:active { background: #1e8a4c; }
.itin-ride-hint {
  margin-top: 4px;
  font-size: 11px;
  color: #8a919c;
}

#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: calc(28px + var(--safe-top)) calc(20px + var(--safe-right)) calc(28px + var(--safe-bottom)) calc(20px + var(--safe-left));
  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 + var(--safe-bottom));
  left: 0;
  right: 0;
  font-size: 11px;
  color: #bbb;
}

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

/* Угол с контролами карты — над панелью «Маршруты» (шапка ~44px + отступ 16px),
   и с отступом от края, чтобы ничего не обрезалось */
.maplibregl-ctrl-bottom-right {
  bottom: calc(var(--safe-bottom) + 70px);
  right: calc(var(--safe-right) + 6px);
}

/* --- Режим «Я в автобусе» --- */
#ride-btn {
  display: block;
  width: 100%;
  margin: 8px 0 4px;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: #27ae60;
  color: #fff;
  text-align: left;
  cursor: pointer;
}
#ride-btn-title { display: block; font-size: 15px; font-weight: 700; }
#ride-btn-sub { display: block; font-size: 12px; opacity: 0.9; margin-top: 2px; }
#ride-btn.active { background: #c0392b; }
#ride-choose-hint {
  margin: 4px 0;
  padding: 8px 10px;
  background: #fef6e0;
  border-radius: 10px;
  font-size: 13px;
  color: #7a5c00;
}
#ride-choose-hint.hidden { display: none; }
.route-detail-stop-row.choosable { cursor: pointer; }
.route-detail-stop-row.choosable:active { background: #f0f7f2; }
.route-detail-stop-row.exit-stop { background: #eafaf0; border-radius: 8px; }
.route-detail-stop-row.exit-stop .route-detail-stop-num { background: #27ae60; color: #fff; }
.route-detail-stop-row.passed { opacity: 0.4; }
.ride-here-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  color: #2980b9;
  font-size: 12px;
  font-weight: 700;
}
.ride-here-row::before, .ride-here-row::after {
  content: "";
  flex: 1;
  border-top: 2px solid #2980b9;
}

#ride-banner {
  cursor: pointer;
  position: absolute;
  top: calc(var(--safe-top) + 58px);
  left: 12px;
  right: 12px;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #2c3e50;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
#ride-banner.hidden { display: none; }
#ride-banner.alarm { background: #e67e22; animation: ride-pulse 1s infinite; }
@keyframes ride-pulse { 50% { box-shadow: 0 0 0 6px rgba(230,126,34,0.35); } }
#ride-banner-badge {
  flex-shrink: 0;
  min-width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  background: rgba(255,255,255,0.18);
  padding: 0 6px;
}
#ride-banner-text { flex: 1; font-size: 13px; line-height: 1.35; }
#ride-banner-stop, #ride-banner-driver {
  flex-shrink: 0;
  border: none;
  background: rgba(255,255,255,0.18);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

#install-hint {
  position: absolute;
  z-index: 6;
  top: calc(var(--safe-top) + 66px);
  right: calc(var(--safe-right) + 12px);
  border: 0;
  border-radius: 18px;
  padding: 8px 12px;
  color: #fff;
  background: rgba(20, 22, 30, .88);
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  font-size: 12px;
}
#install-hint.hidden, #app-toast.hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(8px); }
#install-sheet {
  position: absolute;
  z-index: 1200;
  left: calc(var(--safe-left) + 16px);
  right: calc(var(--safe-right) + 16px);
  bottom: calc(var(--safe-bottom) + 18px);
  background: var(--panel-bg);
  color: var(--panel-text);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
#install-sheet.hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(12px); }
#install-sheet-title { font-weight: 700; font-size: 15px; margin-bottom: 8px; }
#install-sheet ol { margin: 0 0 12px 18px; padding: 0; font-size: 14px; line-height: 1.55; }
#install-sheet-close { border: 0; border-radius: 10px; padding: 9px 14px; background: #2ecc71; color: #102016; font-weight: 700; }
#app-toast {
  position: absolute;
  z-index: 1100;
  left: calc(var(--safe-left) + 16px);
  right: calc(var(--safe-right) + 16px);
  bottom: calc(var(--safe-bottom) + 18px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px 11px 16px;
  border-radius: 14px;
  color: #fff;
  background: rgba(20,22,30,.96);
  box-shadow: 0 5px 20px rgba(0,0,0,.3);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
#app-toast-text { flex: 1; font-size: 13px; }
#app-toast-action { border: 0; border-radius: 9px; padding: 7px 10px; background: #2ecc71; color: #102016; font-weight: 700; }
#app-toast-action.hidden { display: none; }

#stop-sheet-handle, #route-detail-handle, #itinerary-handle {
  position: relative;
  width: 52px;
  height: 20px;
  margin: 0 auto 4px;
  background: transparent;
  touch-action: none;
  cursor: grab;
}
#stop-sheet-handle::after, #route-detail-handle::after, #itinerary-handle::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  height: 4px;
  border-radius: 3px;
  background: #c5c8cc;
}
.sheet-dragging { transition: none !important; }

@media (display-mode: standalone) {
  #install-hint, #install-sheet { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (prefers-color-scheme: dark) {
  :root { --panel-bg: #20232b; --panel-text: #f2f4f7; --panel-muted: #aeb4be; --panel-border: #363b45; }
  #stop-sheet, #itinerary-sheet, #route-detail-sheet, #dest-panel { background: var(--panel-bg); color: var(--panel-text); }
  #stop-sheet-title, #route-detail-fromto, #dest-panel-title { color: var(--panel-text); }
  .stop-route-row, #route-detail-stops-toggle, .route-detail-stop-row { border-color: var(--panel-border); }
  .stop-route-to, .itin-step-title { color: var(--panel-text); }
  .stop-route-sub, #route-detail-meta, .itin-step-sub, #route-detail-stops-toggle { color: var(--panel-muted); }
  #route-detail-close, #itinerary-actions button, #dest-panel-close, .route-detail-stop-num { background: #353a44; color: #f4f6f8; }
  .itinerary-alt, .route-detail-dir, .driver-card-btn { background: #292d35; color: #eef1f4; border-color: #4b515d; }
  .itinerary-alt.selected, .route-detail-dir.selected { background: #e9edf2; color: #161920; border-color: #e9edf2; }
  #ride-choose-hint { background: #493f20; color: #ffe797; }
  .route-detail-stop-row.exit-stop { background: #183c29; }
}

/* --- Карточка места на острове Хон Че (ВинВондерс) --- */
#island-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 calc(18px + var(--safe-right)) calc(14px + var(--safe-bottom)) calc(18px + var(--safe-left));
  transform: translateY(0);
  transition: transform 0.28s cubic-bezier(.22,.8,.3,1), opacity .2s ease, visibility .28s;
  /* will-change: transform убран: постоянный композитный слой шторки — одна из
     причин, по которой iOS Safari не пейнтил скролл-текст внутри неё */
  /* высота — по содержимому; 82vh это только потолок для очень длинных описаний */
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
#island-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}
#island-sheet.hidden { transform: translateY(110%); opacity: 0; visibility: hidden; pointer-events: none; }
#island-sheet-handle {
  position: relative;
  width: 52px;
  height: 20px;
  margin: 0 auto 4px;
  background: transparent;
  touch-action: none;
  cursor: grab;
  flex-shrink: 0;
}
#island-sheet-handle::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  height: 4px;
  border-radius: 3px;
  background: #c5c8cc;
}
#island-sheet-photo {
  width: 100%;
  /* фото не должно съедать экран: раньше 34vh выдавливало описание в скролл */
  height: 24vh;
  max-height: 200px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 10px;
  background: #eef1f4;
  flex-shrink: 0;
}
#island-sheet-zone {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  color: #8e44ad;
  background: rgba(142, 68, 173, 0.12);
  border-radius: 8px;
  padding: 3px 8px;
  margin-bottom: 6px;
}
#island-sheet-title { font-weight: 700; font-size: 17px; }
#island-sheet-subtitle { font-size: 13px; color: #7b8290; margin: 2px 0 8px; }
#island-sheet-desc {
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-line;
  /* своего скролла у описания больше нет — текст показывается целиком,
     при нехватке места скроллится вся карточка (#island-sheet-body) */
  margin-bottom: 12px;
  /* iOS Safari: скролл-область внутри transform-анимируемой шторки иногда не
     отрисовывается (высота есть, текст пустой — скрин Георгия 25.08);
     собственный композит-слой заставляет WebKit её пейнтить */
  transform: translateZ(0);
}
/* .hidden у фото/чипа зоны/ссылки: без этих правил classList.add("hidden")
   ничего не прятал — у точки без фото висел пустой серый блок */
#island-sheet-photo.hidden, #island-sheet-zone.hidden, #island-sheet-link.hidden { display: none; }
#island-sheet-link {
  display: block;
  flex-shrink: 0;
  margin: -4px 0 12px;
  font-size: 14px;
  color: #2c7be5;
  text-decoration: none;
}
#island-sheet-go {
  border: none;
  border-radius: 12px;
  background: #2c7be5;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
  #island-sheet { background: var(--panel-bg); color: var(--panel-text); }
  #island-sheet-subtitle { color: var(--panel-muted); }
  #island-sheet-zone { color: #c39bd3; background: rgba(195, 155, 211, 0.16); }
  #island-sheet-link { color: #6ea8fe; }
}
