* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
#map { position: absolute; inset: 0; }

.ver { font-weight: 400; font-size: 11px; opacity: .8; }
#gps-status.gps-denied { background: #b3261e; color: #fff; padding: 2px 8px; border-radius: 8px; font-weight: 700; cursor: pointer; }

/* HUD сверху */
/* контролы MapLibre (зум, линейка) — ниже шапки GPS-статуса, чтобы не накладывались */
.maplibregl-ctrl-top-left { top: calc(env(safe-area-inset-top) + 40px); }

#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 8px;
  background: linear-gradient(180deg, rgba(13,79,121,.92), rgba(13,79,121,0));
  color: #fff; font-size: 14px; font-weight: 600;
  pointer-events: none; z-index: 10;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
#progress-bar {
  flex-basis: 100%; height: 4px; margin-top: 6px;
  background: rgba(255,255,255,.28); border-radius: 2px; overflow: hidden;
}
#progress-bar.hidden { display: none; }
#progress-fill { display: block; height: 100%; width: 0; background: #fff; transition: width .4s ease; }

/* Кнопки */
#controls {
  position: absolute; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 18px);
  display: flex; flex-direction: column; gap: 10px; z-index: 10;
}
/* на низких экранах (альбомная ориентация) колонка из 6 кнопок не влезает — ужимаем */
@media (max-height: 600px) {
  #controls { gap: 6px; }
  #controls button { width: 44px !important; height: 44px !important; font-size: 17px !important; }
}
#controls button {
  width: 52px; height: 52px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3);
  font-size: 22px; cursor: pointer;
}
#controls button:active { transform: scale(.94); }
/* активный тумблер — заливка + белое кольцо, чтобы было видно на солнце */
#controls button.active { color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 2px 8px rgba(0,0,0,.45); }
#btn-follow.active, #btn-home.active { background: #0d4f79; }
#btn-eco.active, #btn-test.active { background: #d98a00; }
/* аварийный ручной замок при плохом GPS — янтарный + мягкий пульс, чтобы заметили */
#btn-unlock { background: #f6b73c; color: #4a3000; animation: unlockPulse 1.8s ease-in-out infinite; }
#btn-unlock.hidden { display: none; }
@keyframes unlockPulse { 0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,.3); } 50% { box-shadow: 0 0 0 5px rgba(246,183,60,.45), 0 2px 8px rgba(0,0,0,.3); } }

/* Оценка маршрута (звёзды на экране финиша) */
#rate-box { text-align: center; margin: 8px 0 4px; }
#rate-box.hidden { display: none; }
#rate-title { margin: 0 0 6px; font-size: 14px; color: #555; }
#rate-stars button {
  border: none; background: none; font-size: 34px; line-height: 1;
  color: #ccc; cursor: pointer; padding: 2px 6px;
}
#rate-stars button.sel { color: #f5a623; }
#review-box { margin: 6px 0 4px; text-align: center; }
#review-box.hidden { display: none; }
#review-text {
  width: 100%; box-sizing: border-box; padding: 9px; border: 1px solid #cbd5d0;
  border-radius: 9px; font-size: 15px; font-family: inherit; resize: vertical;
}
#review-send {
  margin-top: 6px; padding: 9px 16px; border: none; border-radius: 9px;
  background: #0d4f79; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* Подсказка установки PWA на iOS */
#ios-hint, #install-hint {
  position: absolute; left: 12px; right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 12;
  background: rgba(20,20,20,.92); color: #fff; border-radius: 12px;
  padding: 10px 12px; font-size: 13px; line-height: 1.35;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
#ios-hint.hidden, #install-hint.hidden { display: none; }
#ios-hint button, #install-close {
  flex: 0 0 auto; width: 28px; height: 28px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff; font-size: 14px; cursor: pointer;
}
#install-go {
  flex: 0 0 auto; border: none; border-radius: 8px; background: #2e9e4f; color: #fff;
  font-weight: 700; font-size: 13px; padding: 8px 12px; cursor: pointer;
}

/* Подсказка навигации */
#nav-hint {
  position: absolute; left: 12px; bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 10; background: rgba(13,79,121,.92); color: #fff;
  border-radius: 22px; padding: 8px 14px; display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.3); max-width: 82%;   /* панель рейса длиннее: км + ETA + скорость + борт */
}
#nav-hint.hidden { display: none; }
#nav-arrow { font-size: 18px; display: inline-block; transition: transform .2s; }
/* две строки справа от стрелки: сверху время, снизу направление до точки */
#nav-hint .nav-col { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
#nav-hint .nav-col span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav-time { font-size: 12px; opacity: .85; }

/* Маркеры — нумерованные кружки */
.pin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  cursor: pointer;
  background: #b0b0b0;            /* locked = серый */
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; line-height: 1;
}
.pin.unlocked { background: #2e9e4f; }   /* unlocked = зелёный */
.pin.pin-pulse { animation: pinpulse 1s ease-out infinite; z-index: 5; }
@keyframes pinpulse { 0% { box-shadow: 0 0 0 0 rgba(46,158,79,.7); } 70% { box-shadow: 0 0 0 16px rgba(46,158,79,0); } 100% { box-shadow: 0 0 0 0 rgba(46,158,79,0); } }

/* Объект (музей и т.п.) — синий круглый пин с иконкой */
.opin {
  width: 30px; height: 30px; border-radius: 50%;
  background: #2b6cb0; border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; cursor: pointer; line-height: 1;
}

/* Описание в карточке */
#modal-desc { margin: 12px 0 0; font-size: 15px; line-height: 1.45; color: #2a3a30; white-space: pre-wrap; }
#modal-desc:empty { display: none; }
.sound-spoiler { white-space: normal; }
.side-hint { margin: 2px 0 8px; font-size: 14px; font-weight: 600; color: #0d4f79; }
.sound-spoiler summary { cursor: pointer; color: #0d4f79; font-weight: 600; font-size: 14px; list-style: none; outline: none; }
.sound-spoiler summary::-webkit-details-marker { display: none; }
.sound-spoiler summary::before { content: "▸ "; }
.sound-spoiler[open] summary::before { content: "▾ "; }
.sound-text { margin-top: 8px; font-size: 15px; line-height: 1.5; color: #2a3a30; white-space: pre-wrap; }

/* Метка пользователя */
.me {
  width: 18px; height: 18px; border-radius: 50%;
  background: #1a73e8; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(26,115,232,.25);
}

/* Модалка */
#modal {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px;
}
#modal.hidden, #toast.hidden { display: none; }
.modal-card {
  position: relative; background: #fff; border-radius: 16px;
  width: 100%; max-width: 420px; max-height: 86vh; overflow: auto;
  padding: 18px;
}
.modal-card h2 { margin: 0 36px 12px 0; font-size: 19px; }
.modal-card img {
  width: 100%; border-radius: 10px; display: block; background: #eee;
}
/* превью-точка «попробуй бесплатно»: янтарный пин с подарком + CTA в карточке */
.pin.preview-pin { background: #fff3d6; border-color: #d99a1b; font-size: 15px; }
.pin.preview-pin.unlocked { background: #ffd982; border-color: #b97f10; }
.preview-cta { margin-top: 12px; background: #fff7e6; border: 1px solid #ffe2a8; border-radius: 12px; padding: 12px; font-size: 14px; line-height: 1.45; color: #5a4a20; }
.preview-cta-btn { margin-top: 10px; width: 100%; padding: 11px; border: none; border-radius: 10px; background: #0d4f79; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; }

/* скелетон, пока фото грузится (слабая сеть): мягкий шиммер вместо пустоты */
#modal-photo.ph-wait {
  min-height: 160px;
  background: linear-gradient(100deg, #e6ede8 40%, #f5faf6 50%, #e6ede8 60%);
  background-size: 200% 100%;
  animation: ph-shimmer 1.2s linear infinite;
}
@keyframes ph-shimmer { from { background-position: 120% 0; } to { background-position: -80% 0; } }
#login-submit:disabled { opacity: .6; cursor: default; }
.gallery { position: relative; }
.gal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; font-size: 22px; cursor: pointer;
}
#gal-prev { left: 8px; } #gal-next { right: 8px; }
.gal-nav.hidden { display: none; }
#gal-count {
  position: absolute; bottom: 8px; right: 10px;
  background: rgba(0,0,0,.6); color: #fff; padding: 2px 8px; border-radius: 12px; font-size: 12px;
}
#gal-count:empty { display: none; }
#modal-close {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px; border: none; border-radius: 50%;
  background: #eee; font-size: 16px; cursor: pointer;
}
.modal-audio { margin-top: 14px; }
#modal-replay {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: #0d4f79; color: #fff; font-size: 16px; cursor: pointer;
}
#share-finish, #share-object {
  width: 100%; margin-top: 8px; padding: 11px; border: 1px solid #0d4f79; border-radius: 10px;
  background: #fff; color: #0d4f79; font-size: 15px; font-weight: 600; cursor: pointer;
}
#share-finish.hidden, #share-object.hidden { display: none; }
#finish-more {
  width: 100%; margin-top: 8px; padding: 11px; border: none; border-radius: 10px;
  background: #0d4f79; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
#finish-more.hidden { display: none; }
#modal-replay.pulse { animation: btnpulse 1s ease-in-out infinite; }

/* Плеер озвучки: перемотка + ±15 сек + время */
#audio-player { margin-top: 10px; }
#audio-player.hidden { display: none; }
#audio-seek {
  width: 100%; margin: 0; height: 28px; cursor: pointer;
  accent-color: #0d4f79; touch-action: none;
}
.audio-ctl { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.audio-ctl button {
  border: 1px solid #0d4f79; border-radius: 8px; background: #fff; color: #0d4f79;
  font-size: 15px; font-weight: 600; padding: 7px 14px; cursor: pointer; min-width: 64px;
}
.audio-ctl button:active { background: #e7f0ea; }
#audio-time { font-size: 14px; color: #44524b; font-variant-numeric: tabular-nums; }
@keyframes btnpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(13,79,121,.5); } 50% { box-shadow: 0 0 0 8px rgba(13,79,121,0); } }

/* Индикатор офлайна */
#offline-status {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 42px); z-index: 11;
  background: #fff; border-radius: 14px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.25);
  cursor: pointer; max-width: 90%; text-align: center;
}
/* строки плашки: имя тура, статус; длинное обрезается многоточием */
#offline-status .off-name,
#offline-status .off-time,
#offline-status .off-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#offline-status .off-name { font-weight: 700; }
#offline-status .off-time { font-size: 12px; opacity: .85; }
#offline-status.ok { background: #cde3ec; color: #0d4f79; }
#offline-status.warn { background: #fff4d6; color: #7a5b00; }
#offline-status.err { background: #f3d6d4; color: #8a1a14; }

/* Выбор города / «нас тут пока нет» */
#nocity-overlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,40,28,.92); padding: 16px;
}
#nocity-overlay.hidden { display: none; }
#nocity-overlay .modal-card { max-width: 380px; }
#nocity-list button {
  display: block; width: 100%; margin: 8px 0; padding: 12px;
  border: none; border-radius: 10px; background: #0d4f79; color: #fff;
  font-size: 16px; cursor: pointer;
}
#nocity-cta {
  display: block; margin: 14px 0 0; padding: 12px; border-radius: 10px;
  border: 1.5px solid #0d4f79; background: #e6eef5; color: #0d4f79;
  font-size: 15px; font-weight: 700; text-align: center; text-decoration: none;
}
#nocity-cta.hidden { display: none; }

/* Помощь по доступу к GPS (часто iOS-PWA: разрешение залипает «запрещено») */
#gps-help {
  position: absolute; inset: 0; z-index: 35;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px;
}
#gps-help.hidden { display: none; }
#gps-help .modal-card { max-width: 400px; position: relative; max-height: 86vh; overflow-y: auto; }
#gps-help-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  border: none; border-radius: 50%; background: #eee; cursor: pointer; font-size: 14px;
}
#gps-help-body { font-size: 15px; line-height: 1.5; color: #2c3b32; }
#gps-help-body p { margin: 8px 0; }
#gps-help-body ol { padding-left: 20px; margin: 8px 0; }
#gps-help-body li { margin-bottom: 8px; }

/* О проекте */
#about-overlay {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px;
}
#about-overlay.hidden { display: none; }
#about-overlay .modal-card { max-width: 380px; position: relative; }
#about-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  border: none; border-radius: 50%; background: #eee; cursor: pointer; font-size: 14px;
}
.about-text { margin: 0 0 10px; font-size: 15px; line-height: 1.45; color: #2c3b32; }
.about-contact { margin: 4px 0 10px; font-size: 18px; font-weight: 700; }
.about-contact a { color: #0d4f79; }
.about-ver { font-size: 12px; color: #8a958e; margin: 0; }
.about-h3 { margin: 16px 0 8px; font-size: 16px; color: #0d4f79; }
/* легенда карты в «О проекте» */
.about-legend { display: flex; flex-direction: column; gap: 7px; margin: 4px 0 10px; font-size: 14px; color: #2c3b32; }
.about-legend > div { display: flex; align-items: center; gap: 9px; }
.lg-pin { flex: none; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.lg-route { background: #2c8a4f; color: #fff; }
.lg-start { background: #fff; border: 2px solid #2c8a4f; }
.lg-obj { background: #1b6fb3; }
.lg-line { flex: none; width: 26px; height: 0; border-top: 3px dashed #2c8a4f; }

/* Панель информации (активный маршрут туриста) */
#info-overlay {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px;
}
#info-overlay.hidden { display: none; }
#info-overlay .modal-card { max-width: 400px; position: relative; }
#info-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  border: none; border-radius: 50%; background: #eee; cursor: pointer; font-size: 14px;
}
.info-cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 12px; display: block; margin-bottom: 10px; background: #dce6df; }
.info-route-name { font-size: 18px; font-weight: 700; color: #14321f; margin-bottom: 6px; }
.info-route-desc { font-size: 15px; line-height: 1.45; color: #2c3b32; white-space: pre-wrap; margin-bottom: 10px; }
.info-progress { font-size: 15px; font-weight: 600; color: #0d4f79; margin: 10px 0 6px; }
.btn-finish { width: 100%; margin-top: 6px; padding: 12px; border: none; border-radius: 10px; background: #0d4f79; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn-finish:active { background: #0c3f28; }
.btn-about-open {
  width: 100%; margin-top: 6px; padding: 11px; border: none; border-radius: 10px;
  background: #e6eef5; color: #0d4f79; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-about-open:active { background: #d9ebe0; }

/* Блок компании (управляющего) — в инфо и в каталоге */
.info-company, .cat-company {
  display: flex; gap: 10px; align-items: flex-start;
  background: #f4f8f5; border-radius: 12px; padding: 10px; margin: 8px 0;
}
.info-company .co-logo, .cat-company .co-logo {
  width: 48px; height: 48px; object-fit: contain; border-radius: 8px;
  background: #fff; flex: none; display: block;
}
.co-text { min-width: 0; }
.co-name { font-weight: 700; font-size: 15px; color: #14321f; }
.co-about { font-size: 13px; color: #3c4a40; line-height: 1.4; margin-top: 2px; white-space: pre-wrap; }
.co-contacts { font-size: 13px; color: #0d4f79; line-height: 1.4; margin-top: 4px; white-space: pre-wrap; }

/* Каталог городов/маршрутов в «О проекте» */
.cat-city { border: 1px solid #e2e8e4; border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.cat-city > summary { cursor: pointer; padding: 11px 12px; font-weight: 600; font-size: 15px; background: #f4f8f5; list-style: none; }
.cat-city > summary::-webkit-details-marker { display: none; }
.cat-body { padding: 10px 12px 12px; }
/* каждый администратор города — отдельная карточка: шапка организации + её маршруты под ней */
.cat-group { border: 1px solid #d7e3db; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; background: #fbfdfb; }
.cat-group:last-child { margin-bottom: 0; }
.cat-group .cat-company { background: none; padding: 0 0 8px; margin: 0 0 8px; border-bottom: 1px solid #e6efe9; }
.cat-anon .co-name { color: #44524b; }
/* сворачиваемый список маршрутов организатора */
.cat-routes-d > summary { cursor: pointer; list-style: none; font-size: 13px; font-weight: 600; color: #2c6b46; padding: 4px 0; }
.cat-routes-d > summary::-webkit-details-marker { display: none; }
.cat-routes-d > summary::before { content: "▸ "; color: #6b7a71; }
.cat-routes-d[open] > summary::before { content: "▾ "; }
.cat-routes { padding-left: 12px; border-left: 3px solid #cfe0d5; margin-top: 4px; }
.cat-route { width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 8px 0; border-top: 1px solid #eef2ef; display: flex; gap: 10px; align-items: center; }
.cat-route:first-child { border-top: none; }
.cat-route:active { background: #f1f6f2; }
/* мини-обложка в каталоге: селектор с запасом специфичности — общее правило
   .modal-card img { width:100% } иначе перебивает width:64px и рисует ленту 322×44 */
.modal-card img.cat-cover, img.cat-cover { width: 64px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; background: #dce6df; }
.cat-route-tx { min-width: 0; flex: 1; }
.cat-route-name { font-weight: 600; font-size: 14px; color: #14321f; }
.cat-route-hint { font-size: 12px; color: #2c6b46; margin-top: 2px; }
/* окно с описанием маршрута из каталога */
#cat-route-overlay { position: absolute; inset: 0; z-index: 31; display: flex; align-items: center;
  justify-content: center; padding: 16px; background: rgba(8,30,18,.55); overflow-y: auto; }
#cat-route-overlay.hidden { display: none; }
#cat-route-overlay .modal-card { max-width: 400px; position: relative; }
#cat-route-cover { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; margin-bottom: 10px; }
#cat-route-desc { white-space: pre-wrap; }

/* Оверлей входа */
#login-overlay {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px;
}
#login-overlay.hidden { display: none; }
#login-overlay .modal-card { max-width: 360px; }
#login-overlay .muted { color: #6a7a70; font-size: 14px; margin: 4px 0 12px; }
#login-code {
  width: 100%; padding: 12px; font-size: 20px; text-align: center;
  letter-spacing: 2px; text-transform: uppercase; font-family: ui-monospace, monospace;
  border: 1px solid #cbd5d0; border-radius: 10px;
}
#login-submit {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: #0d4f79; color: #fff; font-size: 16px; cursor: pointer;
}
#login-error { color: #b3261e; font-size: 14px; min-height: 18px; margin-top: 8px; text-align: center; }
.linklike { display: block; margin: 12px auto 0; background: none; border: none;
  color: #6a7a70; text-decoration: underline; cursor: pointer; font-size: 14px; }

/* Тост */
#toast {
  position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; padding: 10px 16px;
  border-radius: 20px; font-size: 14px; z-index: 30; max-width: 80%;
  text-align: center;
}
