* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; background: #e8eaed; color: #202124; -webkit-font-smoothing: antialiased; }
button, input { font-family: inherit; }

#map { position: fixed; inset: 0; z-index: 1; background: #e8eaed; }
.hidden { display: none !important; }

.searchTopBar { position: fixed; top: env(safe-area-inset-top); left: 8px; right: 8px; z-index: 20; padding-top: 8px; }
.searchBox { background: #fff; border-radius: 999px; padding: 4px 8px 4px 16px; display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.18); height: 48px; }
.searchIcon { font-size: 18px; opacity: 0.65; }
.searchBox input { flex: 1; border: 0; outline: 0; font-size: 16px; background: transparent; padding: 0 4px; }
.clearBtn { width: 32px; height: 32px; border-radius: 50%; border: 0; background: #eee; color: #555; font-size: 14px; }

.suggestions { background: #fff; margin-top: 6px; border-radius: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.18); max-height: 60vh; overflow-y: auto; }
.suggItem { padding: 12px 16px; display: flex; gap: 12px; align-items: flex-start; border-bottom: 1px solid #f0f0f0; cursor: pointer; }
.suggItem:last-child { border-bottom: 0; }
.suggItem:active { background: #f5f5f5; }
.suggIco { width: 36px; height: 36px; border-radius: 50%; background: #f1f3f4; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.suggBody { flex: 1; min-width: 0; }
.suggName { font-size: 15px; font-weight: 500; color: #202124; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggAddr { font-size: 13px; color: #5f6368; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.suggDist { font-size: 12px; color: #5f6368; flex-shrink: 0; padding-top: 4px; }

#topBar { position: fixed; top: 0; left: 8px; right: 8px; z-index: 22; margin-top: calc(env(safe-area-inset-top) + 8px); padding: 14px 14px; background: #003c2f; color: #fff; border-radius: 16px; display: flex; align-items: center; gap: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.instrIcon { font-size: 38px; line-height: 1; flex-shrink: 0; color: #fff; font-weight: 300; }
.instr { flex: 1; min-width: 0; }
.instrDist { font-size: 26px; font-weight: 600; line-height: 1; }
.instrText { font-size: 15px; font-weight: 500; opacity: 0.95; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muteBtn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,0.15); color: #fff; font-size: 16px; flex-shrink: 0; }

.countryBadge {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translateX(-50%);
  background: #fff; color: #202124; padding: 6px 14px; border-radius: 16px;
  font-size: 12px; font-weight: 600; z-index: 18;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.radarBadge { position: fixed; top: calc(env(safe-area-inset-top) + 110px); right: 14px; background: #ea4335; color: #fff; padding: 8px 12px; border-radius: 14px; z-index: 12; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 16px rgba(234,67,53,0.5); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.07)} }
.radarIco { font-size: 22px; }
.radarLbl { font-size: 9px; opacity: 0.85; letter-spacing: 1px; }
.radarDist { font-size: 17px; font-weight: 700; }

.speedHud { position: fixed; bottom: calc(env(safe-area-inset-bottom) + 110px); left: 14px; background: #fff; color: #202124; border-radius: 50%; width: 76px; height: 76px; z-index: 12; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 4px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.25); transition: border-color 0.2s, background 0.2s; }
.speedHud.over { border-color: #ea4335; background: #fce8e6; }
.curSpeed { font-size: 26px; font-weight: 700; line-height: 1; }
.curLabel { font-size: 9px; color: #5f6368; }
.limit { position: absolute; bottom: -8px; right: -8px; background: #fff; border: 3px solid #ea4335; border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #202124; }

.recenterBtn { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 110px); background: #fff; color: #00695c; border-radius: 28px; padding: 10px 18px; z-index: 13; display: flex; align-items: center; gap: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.25); font-size: 14px; font-weight: 600; cursor: pointer; }
.recenterIco { font-size: 16px; }

.myLocBtn { position: fixed; right: 14px; bottom: calc(env(safe-area-inset-bottom) + 220px); width: 44px; height: 44px; border-radius: 50%; background: #fff; color: #1a73e8; z-index: 12; display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 2px 6px rgba(0,0,0,0.2); cursor: pointer; }
.rerouteBtn { position: fixed; right: 14px; bottom: calc(env(safe-area-inset-bottom) + 274px); width: 44px; height: 44px; border-radius: 50%; background: #fff; color: #1a73e8; z-index: 12; display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: 0 2px 6px rgba(0,0,0,0.2); cursor: pointer; }

.bottomSheet { position: fixed; bottom: 0; left: 0; right: 0; z-index: 9; background: #fff; border-radius: 16px 16px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom) + 16px); box-shadow: 0 -2px 8px rgba(0,0,0,0.12); max-height: 60vh; overflow-y: auto; }
.sheetHandle { width: 36px; height: 4px; border-radius: 2px; background: #dadce0; margin: 0 auto 12px; }
.quickRow { display: flex; gap: 8px; flex-wrap: wrap; }
.quickChip { flex: 1; min-width: 90px; background: #f1f3f4; border: 0; padding: 10px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: #202124; }
.quickIco { font-size: 20px; }
.prefsRow { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 0 4px; }
.pref { font-size: 13px; display: flex; align-items: center; gap: 6px; color: #3c4043; }
.pref input { width: 16px; height: 16px; }

.actionsBig { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bigBtn { width: 100%; padding: 14px; border: 0; border-radius: 28px; font-size: 15px; font-weight: 600; cursor: pointer; }
.bigBtn.dark { background: #202124; color: #fff; }
.bigBtn.green { background: #1a73e8; color: #fff; }
.bigBtn.light { background: #f1f3f4; color: #202124; }
.status { margin-top: 10px; font-size: 12px; color: #5f6368; text-align: center; }

.routePreview { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: #fff; border-radius: 18px 18px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); box-shadow: 0 -4px 16px rgba(0,0,0,0.18); }
.previewHead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.previewTitle { font-size: 16px; font-weight: 600; flex: 1; }
#previewClose { background: none; border: 0; font-size: 18px; color: #5f6368; padding: 4px 8px; }
.previewMetrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.metricBig { text-align: center; padding: 10px; background: #f1f3f4; border-radius: 12px; }
.metricVal { font-size: 18px; font-weight: 700; color: #1a73e8; }
.metricLbl { font-size: 11px; color: #5f6368; margin-top: 2px; }
.previewActions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.bottomBar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: #fff; color: #202124; padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px); border-radius: 18px 18px 0 0; display: flex; align-items: center; gap: 12px; box-shadow: 0 -4px 16px rgba(0,0,0,0.15); }
.metaRow { flex: 1; }
.eta { font-size: 24px; font-weight: 700; line-height: 1; color: #d93025; }
.meta { font-size: 13px; color: #5f6368; margin-top: 4px; }
.stop { background: #ea4335; color: #fff; border: 0; padding: 12px 22px; border-radius: 22px; font-size: 14px; font-weight: 600; }

.car-arrow { width: 0; height: 0; border-left: 12px solid transparent; border-right: 12px solid transparent; border-bottom: 28px solid #1a73e8; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)); }

/* DRAWER (Tools) */
.drawer { position: fixed; left: 0; right: 0; bottom: 0; top: 8vh; z-index: 25; background: #fff; border-radius: 18px 18px 0 0; padding: 16px; overflow-y: auto; box-shadow: 0 -4px 24px rgba(0,0,0,0.25); }
.drawerHead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.drawerHead h2 { margin: 0; font-size: 18px; }
.drawerHead button { background: #f1f3f4; border: 0; font-size: 16px; width: 36px; height: 36px; border-radius: 50%; }
.toolGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.tool { padding: 14px; border: 0; border-radius: 14px; background: #f1f3f4; font-size: 13px; line-height: 1.6; color: #202124; cursor: pointer; }
.tool:active { background: #e0e2e5; }
.toolContent { padding: 14px; background: #f8f9fa; border-radius: 12px; font-size: 14px; line-height: 1.55; color: #202124; }
.toolContent h3 { margin: 0 0 10px; font-size: 15px; color: #1a73e8; }
.toolContent button { margin-top: 8px; padding: 8px 14px; border-radius: 8px; border: 1px solid #dadce0; background: #fff; font-size: 13px; cursor: pointer; }
.toolContent .ruleRow { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid #e8eaed; }
.toolContent .ruleRow:last-child { border-bottom: 0; }
.toolContent .ruleRow b { min-width: 70px; }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modalCard { background: #fff; padding: 18px; border-radius: 16px; max-width: 380px; width: 100%; }
.modalCard h2 { margin: 0 0 12px; font-size: 17px; }
.compareBox { padding: 12px; border: 1px solid #e8eaed; border-radius: 12px; margin-bottom: 10px; font-size: 13px; }
.compareBox h3 { margin: 0 0 6px; font-size: 14px; color: #1a73e8; }
.compareBox p { margin: 4px 0; }

/* V7: Alternatives + Warnings in preview */
.previewAlternatives { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; }
.altCard { flex: 1; min-width: 100px; background: #f1f3f4; border: 2px solid transparent; padding: 10px; border-radius: 12px; text-align: left; cursor: pointer; }
.altCard:active { background: #e0e2e5; }
.altCardSel { border-color: #1a73e8; background: #e8f0fe; }
.altLabel { font-size: 11px; color: #5f6368; text-transform: uppercase; letter-spacing: 0.5px; }
.altMain { font-size: 16px; font-weight: 700; color: #202124; margin-top: 2px; }
.altSub { font-size: 12px; color: #5f6368; }

.previewWarnings { background: #fef7e0; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.warnItem { font-size: 13px; color: #5f3e00; padding: 3px 0; }

/* V8: Nav side buttons (Google Maps style on right) */
.navSideButtons {
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%);
  z-index: 14;
  display: flex; flex-direction: column; gap: 12px;
}
.navSideBtn {
  width: 48px; height: 48px;
  background: #fff; border: 0; border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.navSideBtn:active { background: #f1f3f4; }
