
:root{--bg:#071830;--panel:#0d2748;--panel2:#12345c;--text:#f5f8ff;--muted:#9db2cc;--accent:#2b8cff;--danger:#ffb020;--line:#23466f;--shadow:0 12px 30px rgba(0,0,0,.28)}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;background:var(--bg);color:var(--text);overscroll-behavior:none}
body.light{--bg:#edf4fb;--panel:#fff;--panel2:#e6f0fb;--text:#0b1f38;--muted:#526b84;--line:#cbd9e7;--shadow:0 10px 25px rgba(25,55,85,.12)}
button{font:inherit;color:inherit}
.topbar{height:calc(70px + env(safe-area-inset-top));padding:env(safe-area-inset-top) 16px 0;display:flex;align-items:center;gap:12px;background:linear-gradient(180deg,#071830,#0a2140);position:sticky;top:0;z-index:20;border-bottom:1px solid var(--line)}
.brand-icon{width:44px;height:44px;border-radius:12px}.topbar h1{margin:0;font-size:22px}.status{font-size:12px;color:var(--muted)}
.icon-btn,.round{border:1px solid var(--line);background:rgba(13,39,72,.92);border-radius:50%;display:grid;place-items:center;box-shadow:var(--shadow)}
.icon-btn{margin-left:auto;width:42px;height:42px;font-size:20px}
main{min-height:calc(100% - 70px)}.view{display:none;padding:18px 16px 110px}.view.active{display:block}
.hero{padding:18px 4px}.hero h2,.section-head h2{margin:0 0 6px}.hero p,.section-head p{margin:0;color:var(--muted)}
.grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.sector-btn,.list-item,.secondary{border:1px solid var(--line);background:var(--panel);border-radius:18px;box-shadow:var(--shadow)}
.sector-btn{padding:24px 14px;min-height:110px;text-align:left;font-weight:800;font-size:17px}
.sector-btn span{display:block;color:var(--accent);font-size:26px;margin-bottom:10px}
.home-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:16px}.secondary{padding:14px}
.section-head{display:flex;align-items:center;gap:12px;margin-bottom:16px}.backBtn{width:42px;height:42px;border-radius:50%;border:1px solid var(--line);background:var(--panel);font-size:30px}
.list{display:flex;flex-direction:column;gap:10px}.list-item{padding:15px 16px;text-align:left;display:flex;align-items:center;justify-content:space-between}.list-item b{font-size:17px}.list-item small{display:block;color:var(--muted);margin-top:3px}.chev{color:var(--accent);font-size:24px}
.map-view{padding:0;height:calc(100vh - 70px);position:relative;overflow:hidden}.map-view.active{display:block}.map-view #map{position:absolute;inset:0;background:#d7e1eb}
.map-top{position:absolute;top:12px;left:12px;right:12px;z-index:500;display:flex;gap:8px;align-items:center}.round{width:44px;height:44px;flex:none;font-size:20px}
.route-card{flex:1;background:rgba(7,24,48,.92);border:1px solid var(--line);border-radius:15px;padding:9px 12px;box-shadow:var(--shadow);overflow:hidden}.route-card strong,.route-card span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.route-card span{font-size:12px;color:#b8c9dc;margin-top:2px}
.warning{position:absolute;z-index:550;top:75px;left:12px;right:12px;background:#5a3900;color:#fff5d6;border:1px solid #b87b08;padding:11px;border-radius:12px;text-align:center;font-weight:700}.hidden{display:none!important}
.nav-card{position:absolute;z-index:500;left:12px;right:12px;bottom:calc(76px + env(safe-area-inset-bottom));background:rgba(7,24,48,.94);border:1px solid var(--line);border-radius:20px;padding:14px;box-shadow:var(--shadow)}
.instruction{font-size:18px;font-weight:800}.subinfo,.stats{font-size:12px;color:#b8c9dc}.subinfo{margin-top:4px}.progress{height:5px;background:#24415f;border-radius:8px;margin:12px 0;overflow:hidden}.progress>div{height:100%;width:0;background:#2b8cff}.stats{display:flex;justify-content:space-between}
.map-controls{position:absolute;z-index:500;right:12px;top:92px;display:flex;flex-direction:column;gap:8px}
.start-btn{position:absolute;z-index:550;bottom:calc(16px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);border:0;border-radius:999px;background:#1677ff;color:white;padding:14px 26px;font-weight:800;box-shadow:var(--shadow);min-width:210px}
.settings-card,.notice{background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:8px 16px;box-shadow:var(--shadow)}.settings-card label{display:flex;justify-content:space-between;align-items:center;padding:16px 0;border-bottom:1px solid var(--line)}.settings-card label:last-child{border:0}.settings-card input{width:22px;height:22px}.notice{margin-top:14px}.notice p{color:var(--muted);line-height:1.45}
.toast{position:fixed;z-index:1000;left:50%;bottom:30px;transform:translateX(-50%);background:#000d;color:#fff;padding:10px 16px;border-radius:999px;max-width:90%;text-align:center}
.user-marker{width:22px;height:22px;background:#1677ff;border:3px solid white;border-radius:50%;box-shadow:0 0 0 6px #1677ff44}
.dest-marker{font-size:28px}.stop-marker{width:10px;height:10px;border-radius:50%;background:#fff;border:3px solid #1b6fe5}
@media (max-width:370px){.grid{grid-template-columns:1fr}.sector-btn{min-height:80px}.topbar h1{font-size:20px}}


html,body{
  width:100%;
  height:100%;
  overflow:hidden !important;
  position:fixed;
  inset:0;
  overscroll-behavior:none;
  touch-action:manipulation;
}
body{min-height:100dvh;max-height:100dvh}
main{height:calc(100dvh - 70px - env(safe-area-inset-top));overflow:hidden}
.view{height:100%;overflow-y:auto;-webkit-overflow-scrolling:touch}
.map-view{
  position:fixed !important;
  left:0;right:0;
  top:calc(70px + env(safe-area-inset-top));
  bottom:0;
  height:auto !important;
  overflow:hidden !important;
  touch-action:none;
}
.map-view #map{touch-action:none}
.map-view.active{overflow:hidden !important}

.tutorial-wide{grid-column:1/-1}
.tutorial-card{display:flex;flex-direction:column;gap:12px}
.tutorial-step{display:flex;gap:12px;align-items:flex-start;background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:14px;box-shadow:var(--shadow)}
.step-num{width:34px;height:34px;border-radius:50%;background:var(--accent);color:#fff;display:grid;place-items:center;font-weight:800;flex:none}
.tutorial-step h3{margin:0 0 5px;font-size:16px}
.tutorial-step p{margin:0;color:var(--muted);line-height:1.45}
.vehicle-arrow{width:0;height:0;border-left:10px solid transparent;border-right:10px solid transparent;border-bottom:24px solid #1677ff;filter:drop-shadow(0 2px 3px rgba(0,0,0,.4));transform-origin:50% 60%}

.install-prompt{
  position:fixed;
  inset:0;
  z-index:99999;
  background:rgba(0,0,0,.55);
  display:grid;
  place-items:end center;
  padding:16px;
  padding-bottom:calc(16px + env(safe-area-inset-bottom));
}
.install-prompt.hidden{display:none}
.install-card{
  position:relative;
  width:min(100%,520px);
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:22px;
  padding:22px 18px 18px;
  box-shadow:0 18px 60px rgba(0,0,0,.35);
}
.install-close{
  position:absolute;
  right:12px;
  top:10px;
  width:36px;
  height:36px;
  border:0;
  background:transparent;
  color:inherit;
  font-size:28px;
}
.install-icon{font-size:36px;margin-bottom:6px}
.install-card h2{margin:0 36px 8px 0;font-size:22px}
.install-card p{margin:0 0 14px;color:var(--muted);line-height:1.45}
.ios-install-steps{
  display:flex;
  flex-direction:column;
  gap:9px;
  background:rgba(127,127,127,.10);
  border-radius:14px;
  padding:12px;
  margin-bottom:14px;
  line-height:1.4;
}
.install-ok{width:100%;margin-top:2px}
.install-hide-row{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:12px;
  font-size:13px;
  color:var(--muted);
}

.nav-guidance{position:absolute;z-index:900;left:10px;right:10px;top:10px;background:rgba(10,28,55,.94);color:#fff;border-radius:18px;padding:12px;box-shadow:0 6px 20px rgba(0,0,0,.3);backdrop-filter:blur(8px)}
.nav-guidance.hidden{display:none}
.guide-turn{display:flex;gap:12px;align-items:center}
.guide-icon{font-size:42px;width:52px;text-align:center;font-weight:900}
.guide-body{display:flex;flex-direction:column;min-width:0}.guide-body small,.guide-stop small{opacity:.7;font-size:10px;font-weight:800;letter-spacing:.7px}
.guide-body strong,.guide-stop strong{font-size:17px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.guide-body span{font-size:14px;margin-top:2px}
.guide-stop{border-top:1px solid rgba(255,255,255,.16);margin-top:9px;padding-top:9px;display:flex;justify-content:space-between;align-items:end;gap:10px}
.guide-stop>div{display:flex;flex-direction:column;min-width:0}.guide-stop b{white-space:nowrap}
.guide-progress{display:grid;grid-template-columns:1fr auto auto;gap:8px;align-items:center;margin-top:9px;font-size:11px}
.guide-track{height:5px;background:rgba(255,255,255,.2);border-radius:99px;overflow:hidden}.guide-track>div{height:100%;width:0;background:#fff;border-radius:99px}
#map{height:100%}
.step-num{font-size:10px}

.nav-exit-bar{
  position:absolute;
  z-index:950;
  left:10px;
  right:10px;
  top:10px;
  display:flex;
  justify-content:space-between;
  pointer-events:none;
}
.nav-exit-btn{
  pointer-events:auto;
  min-height:42px;
  padding:0 14px;
  border:0;
  border-radius:14px;
  background:rgba(10,28,55,.94);
  color:#fff;
  font-weight:800;
  font-size:14px;
  box-shadow:0 4px 14px rgba(0,0,0,.28);
  backdrop-filter:blur(8px);
}
.nav-home-btn{background:rgba(10,28,55,.94)}
/* leave room for exit buttons above the guidance card */
.nav-guidance{top:62px}

#androidInstallBtn.hidden,#iosInstallSteps.hidden,#androidInstallSteps.hidden{display:none!important}

/* v1.7.2 — navigation header collision fix */
.nav-exit-bar{
  top:10px;
  left:12px;
  right:12px;
  gap:10px;
  justify-content:space-between;
}
.nav-exit-btn{
  min-height:40px;
  padding:0 12px;
  font-size:13px;
  border-radius:13px;
}
/* Reserve a dedicated band for Indietro/Home, then place guidance below it. */
.nav-guidance{
  top:64px !important;
  left:12px;
  right:12px;
}
/* Move the original route title/header below the exit controls when navigating. */
.map-view .route-head,
.map-view .map-header,
.map-view .route-title{
  margin-top:54px;
}
/* On narrow iPhones keep both controls compact. */
@media (max-width:390px){
  .nav-exit-btn{font-size:12px;padding:0 10px;min-height:38px}
  .nav-guidance{top:60px !important}
}

/* v1.7.3 — definitive top layout fix
   Previous build moved selectors that do not exist in this screen.
   The real Linea/Direzione container is .map-top. */

.nav-exit-bar{
  top:10px !important;
  left:12px !important;
  right:12px !important;
  height:42px;
  z-index:1000 !important;
}

/* Linea + direzione now has its own row BELOW Indietro/Home */
.map-view .map-top{
  top:62px !important;
  left:12px !important;
  right:12px !important;
  z-index:850 !important;
}

/* The old round back button is redundant because we now have "Indietro". */
.map-view #mapBackBtn{
  display:none !important;
}

/* Guidance panel goes below the Linea/Direzione row. */
.map-view .nav-guidance{
  top:126px !important;
  left:12px !important;
  right:12px !important;
  z-index:900 !important;
}

/* Keep warning and map buttons away from the new top stack. */
.map-view .warning{
  top:282px !important;
}
.map-view .map-controls{
  top:300px !important;
}

@media (max-width:390px){
  .nav-exit-bar{height:38px}
  .map-view .map-top{top:58px !important}
  .map-view .nav-guidance{top:120px !important}
  .map-view .warning{top:276px !important}
  .map-view .map-controls{top:294px !important}
}

/* =========================================================
   v1.7.4 — CLEAN NAVIGATION UI
   Full map, one compact top bar, compact turn card.
   ========================================================= */

.map-view{
  overflow:hidden !important;
}

/* old duplicated floating exit bar is gone */
.nav-exit-bar{display:none!important}

/* Unified top header: Back | Route | Audio | Home */
.map-view .clean-map-top{
  position:absolute!important;
  top:10px!important;
  left:10px!important;
  right:10px!important;
  z-index:1000!important;
  display:grid!important;
  grid-template-columns:42px minmax(0,1fr) 42px 42px!important;
  gap:7px!important;
  align-items:center!important;
  margin:0!important;
}

.map-view .clean-nav-btn{
  width:42px!important;
  height:42px!important;
  min-width:42px!important;
  border-radius:14px!important;
  font-size:19px!important;
  background:rgba(9,27,52,.94)!important;
  box-shadow:0 3px 12px rgba(0,0,0,.24)!important;
}

.map-view .clean-route-card{
  min-width:0!important;
  height:42px!important;
  padding:5px 11px!important;
  border-radius:14px!important;
  background:rgba(9,27,52,.94)!important;
  display:flex!important;
  flex-direction:column!important;
  justify-content:center!important;
  box-shadow:0 3px 12px rgba(0,0,0,.24)!important;
}

.map-view .clean-route-card strong{
  font-size:15px!important;
  line-height:17px!important;
  white-space:nowrap!important;
  overflow:hidden!important;
  text-overflow:ellipsis!important;
}
.map-view .clean-route-card span{
  font-size:10px!important;
  line-height:13px!important;
  white-space:nowrap!important;
  overflow:hidden!important;
  text-overflow:ellipsis!important;
}

/* Compact turn/stop card: no giant block covering the map */
.map-view .nav-guidance{
  top:61px!important;
  left:10px!important;
  right:10px!important;
  padding:9px 11px!important;
  border-radius:15px!important;
  background:rgba(9,27,52,.92)!important;
  box-shadow:0 4px 14px rgba(0,0,0,.22)!important;
  backdrop-filter:blur(7px)!important;
}

.map-view .guide-turn{
  gap:8px!important;
  min-height:38px!important;
}
.map-view .guide-icon{
  width:36px!important;
  font-size:30px!important;
  line-height:32px!important;
}
.map-view .guide-body small,
.map-view .guide-stop small{
  font-size:8px!important;
  letter-spacing:.6px!important;
}
.map-view .guide-body strong{
  font-size:14px!important;
  line-height:16px!important;
}
.map-view .guide-body span{
  font-size:11px!important;
  margin-top:0!important;
}

.map-view .guide-stop{
  margin-top:5px!important;
  padding-top:5px!important;
}
.map-view .guide-stop strong{
  font-size:12px!important;
  line-height:14px!important;
}
.map-view .guide-stop b{
  font-size:12px!important;
}

.map-view .guide-progress{
  margin-top:5px!important;
  font-size:9px!important;
  gap:6px!important;
}
.map-view .guide-track{height:3px!important}

/* Warning becomes a small pill instead of a large banner. */
.map-view .warning{
  top:166px!important;
  left:50%!important;
  right:auto!important;
  transform:translateX(-50%)!important;
  width:max-content!important;
  max-width:calc(100% - 24px)!important;
  padding:6px 10px!important;
  border-radius:999px!important;
  font-size:11px!important;
  white-space:nowrap!important;
  z-index:980!important;
}

/* Controls start under the compact navigation stack. */
.map-view .map-controls{
  top:166px!important;
  right:10px!important;
  gap:7px!important;
}
.map-view .map-controls .round{
  width:42px!important;
  height:42px!important;
}

/* The old large bottom navigation card duplicated information shown above.
   Keep it hidden while navigating so the map remains visible. */
.map-view.nav-active .nav-card{
  display:none!important;
}

/* During navigation the bottom button is also hidden: leaving is handled
   by Back and Home in the top bar. */
.map-view.nav-active .start-btn{
  display:none!important;
}

/* Before navigation, keep the normal bottom summary/start controls. */
.map-view:not(.nav-active) .nav-card{
  display:block;
}

/* Safe area on iPhones */
@supports (top: env(safe-area-inset-top)){
  .map-view .clean-map-top{
    top:calc(8px + env(safe-area-inset-top))!important;
  }
  .map-view .nav-guidance{
    top:calc(59px + env(safe-area-inset-top))!important;
  }
  .map-view .warning,
  .map-view .map-controls{
    top:calc(164px + env(safe-area-inset-top))!important;
  }
}

@media (max-width:390px){
  .map-view .clean-map-top{
    grid-template-columns:39px minmax(0,1fr) 39px 39px!important;
    gap:5px!important;
  }
  .map-view .clean-nav-btn{
    width:39px!important;height:39px!important;min-width:39px!important;
  }
  .map-view .clean-route-card{height:39px!important;padding:4px 9px!important}
  .map-view .clean-route-card strong{font-size:14px!important}
  .map-view .clean-route-card span{font-size:9px!important}
}

/* =========================================================
   v1.7.6 — TOP BAR POSITION FIX
   IMPORTANT: layout-only change. No JavaScript changed.
   The map-view already starts BELOW the iPhone safe area,
   therefore child controls must NOT add env(safe-area-inset-top) again.
   ========================================================= */

@supports (top: env(safe-area-inset-top)){
  .map-view .clean-map-top{
    top:8px!important;
  }

  .map-view .nav-guidance{
    top:59px!important;
  }

  .map-view .warning,
  .map-view .map-controls{
    top:164px!important;
  }
}

/* Keep the unified bar very close to the top edge of the map. */
.map-view .clean-map-top{
  top:8px!important;
}


/* =========================================================
   v1.7.10 — HARD GPS CENTER LOCK
   During navigation the vehicle arrow is a fixed overlay at the exact
   screen/map viewport centre. The Leaflet map moves underneath it.
   ========================================================= */
.center-vehicle{
  position:absolute;
  left:50%;
  top:50%;
  width:30px;
  height:34px;
  transform:translate(-50%,-50%);
  z-index:1100;
  pointer-events:none;
  display:flex;
  align-items:center;
  justify-content:center;
}
.center-vehicle.hidden{display:none!important}
.center-vehicle-arrow{
  width:0;
  height:0;
  border-left:11px solid transparent;
  border-right:11px solid transparent;
  border-bottom:27px solid #1677ff;
  filter:drop-shadow(0 2px 4px rgba(0,0,0,.55));
  transform-origin:50% 55%;
}
