/* ===========================================================
   Wproo Run — Liquid Glass Design System
   Paleta: base quase-preta indigo, painéis translúcidos,
   acentos violeta/roxo, leituras estilo relógio esportivo.
   =========================================================== */

:root {
  /* cor */
  --bg-base:        #0B0B14;
  --bg-elevated:     #12121F;
  --glass-fill:      rgba(255, 255, 255, 0.06);
  --glass-fill-strong: rgba(255, 255, 255, 0.10);
  --glass-border:    rgba(255, 255, 255, 0.12);
  --violet:          #8B5CF6;
  --violet-strong:   #7C3AED;
  --purple:          #A855F7;
  --lilac:           #C084FC;
  --success:         #34D399;
  --warning:         #FBBF24;
  --danger:          #F87171;
  --text-primary:    #F5F3FF;
  --text-muted:      #9CA3AF;
  --text-faint:      #6B7280;

  /* tipografia */
  --font-display: 'Outfit', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* forma */
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  /* sombra de vidro */
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* Trava o zoom por pinça/duplo-toque do NAVEGADOR na interface inteira.
   Cada elemento herda esse valor via seletor universal porque touch-action
   não é uma propriedade herdada de verdade — precisa ser aplicada em cada
   elemento, não só no body. O mapa recebe "none" logo abaixo pra devolver
   o controle do toque pro Leaflet (que faz o próprio zoom/arraste). */
*, *::before, *::after {
  touch-action: pan-x pan-y;
}
#map, #map-active, #map-summary, #map-detail, .leaflet-container {
  touch-action: none;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ===================== estrutura de telas ===================== */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

#map, #map-active { position: absolute; inset: 0; z-index: 0; }
.leaflet-container { background: var(--bg-base) !important; }

/* radar/glow sutil sobre o mapa para casar com a paleta */
#screen-home::after,
#screen-active::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(139, 92, 246, 0.18), transparent 60%);
}

/* ===================== vidro (glass) base ===================== */

.glass-panel {
  background: linear-gradient(180deg, var(--glass-fill-strong), var(--glass-fill));
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
}

.glass-pill {
  background: var(--glass-fill-strong);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--glass-shadow);
}

/* ===================== splash ===================== */

.splash-wrap {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.splash-ring { position: relative; width: 120px; height: 120px; }
.splash-svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.splash-track {
  fill: none;
  stroke: var(--glass-fill-strong);
  stroke-width: 6;
}
.splash-progress {
  fill: none;
  stroke: var(--violet);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  animation: splash-fill 1.6s ease-in-out infinite;
}
@keyframes splash-fill {
  0%   { stroke-dashoffset: 327; }
  50%  { stroke-dashoffset: 60; }
  100% { stroke-dashoffset: 327; }
}
.splash-mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--lilac), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.splash-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  margin: 0;
}
.splash-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* ===================== barra superior ===================== */

.top-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 0;
}

.icon-pill {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-primary);
}
.icon-pill-spacer {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

#btn-history {
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.35);
  color: #fff;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.gps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.gps-dot.locked { background: var(--success); box-shadow: 0 0 8px var(--success); animation: none; }

#gps-status {
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.35);
  color: #fff;
}

.status-pill.live { color: var(--danger); }
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: pulse-dot 1.1s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ===================== painel inferior — início ===================== */

.bottom-panel {
  position: absolute;
  z-index: 2;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  padding: 22px 22px calc(env(safe-area-inset-bottom, 0px) + 22px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.goal-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.goal-label { font-size: 13px; color: var(--text-muted); }
.goal-value {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--lilac);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.28);
}
.goal-edit-icon { opacity: 0.75; }
.goal-value-disabled {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--glass-border);
}
.goal-value-disabled .goal-edit-icon { opacity: 0.3; }

.mode-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.mode-chip {
  flex: 1;
  padding: 9px 2px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.mode-chip.active {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.5);
  color: var(--lilac);
}

.start-btn {
  position: relative;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--purple), var(--violet-strong) 70%);
  box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.12), 0 10px 30px rgba(124, 58, 237, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}
.start-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  letter-spacing: 0.5px;
  color: #fff;
  text-align: center;
}
.start-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(139, 92, 246, 0.5);
  animation: ring-pulse 2.2s ease-out infinite;
}
@keyframes ring-pulse {
  0%   { transform: scale(0.92); opacity: 0.9; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { opacity: 0; }
}

/* ===================== corrida ativa — dock de estatísticas ===================== */

.stats-dock {
  position: absolute;
  z-index: 2;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 108px);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}
.stat-main-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--violet-strong), var(--lilac));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-main-unit {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.stat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.92);
}
.stat-cell-label {
  font-size: 10.5px;
  color: rgba(17, 24, 39, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stat-cell-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.active-controls {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  display: flex;
  justify-content: center;
  gap: 22px;
}
.ctrl-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glass-shadow);
}
.pause-btn {
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  border: 1px solid rgba(139, 92, 246, 0.5);
  color: #fff;
}
.finish-btn {
  background: radial-gradient(circle at 35% 30%, #F87171, #DC2626 75%);
  color: #fff;
}

/* ===================== resumo ===================== */

.summary-scroll {
  height: 100%;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(139, 92, 246, 0.16), transparent 55%),
    var(--bg-base);
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.summary-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0;
}
.detail-header-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.detail-header-title h2 { font-size: 15.5px; }
.detail-header-date {
  font-size: 11.5px;
  color: var(--text-muted);
}

.summary-map {
  height: 200px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.summary-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px;
}
.summary-hero-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 48px;
  background: linear-gradient(135deg, var(--violet-strong), var(--lilac));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.summary-hero-unit { font-size: 13px; color: var(--text-muted); }

.summary-goal-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--lilac);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.summary-goal-badge.reached {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--success);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.summary-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
}
.summary-card-label { font-size: 12px; color: var(--text-muted); }
.summary-card-value { font-family: var(--font-mono); font-size: 20px; font-weight: 600; }

.save-btn {
  margin-top: 4px;
  padding: 16px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.4);
}

/* ===================== histórico ===================== */

#screen-history { background: var(--bg-base); }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 6px;
}
.history-header h2 { font-family: var(--font-display); font-size: 18px; margin: 0; }

.history-tabs {
  display: flex;
  gap: 8px;
  padding: 6px 16px 12px;
}
.history-tab {
  flex: 1;
  padding: 9px 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.history-tab.active {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.5);
  color: var(--lilac);
}

.history-tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  flex-direction: column;
}
.history-tab-panel.active { display: flex; }

.history-summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 16px;
}
.history-summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 6px;
}
.history-summary-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--lilac);
}
.history-summary-label { font-size: 11px; color: var(--text-muted); }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===================== gráficos de evolução (semana / mês / splits) ===================== */

.evolution-summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 16px 4px;
}
.evolution-summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 4px;
}
.evolution-summary-value {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--lilac);
}
.evolution-summary-label {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

.detail-section-title {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 18px 0 2px;
  padding: 0 16px;
}

.evolution-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  min-height: 170px;
}
.evo-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
  min-width: 0;
}
.evo-bar-value {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.evo-bar-track {
  width: 100%;
  max-width: 30px;
  height: 110px;
  display: flex;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  overflow: hidden;
}
.evo-bar-fill {
  width: 100%;
  height: 2%;
  background: linear-gradient(180deg, var(--lilac), var(--violet-strong));
  border-radius: 6px 6px 0 0;
  transition: height 0.5s ease;
}
.evo-bar-fill.best {
  background: linear-gradient(180deg, var(--success), #16a34a);
}
.evo-bar-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  white-space: nowrap;
}
.evolution-chart-empty {
  margin: auto;
  padding: 20px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ===================== gráfico de evolução de velocidade (linha/área) ===================== */

.detail-speed-wrap {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-speed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.detail-speed-title { margin: 0; padding: 0; }

.detail-speed-legend {
  display: flex;
  gap: 12px;
}
.speed-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}
.speed-legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.speed-legend-dot.avg { background: var(--lilac); opacity: 0.7; border: 1px dashed var(--lilac); background: transparent; border-color: var(--lilac); }
.speed-legend-dot.max { background: var(--success); }

.speed-chart {
  width: 100%;
  height: 130px;
  margin-top: 6px;
}
.speed-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }

.detail-speed-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.speed-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}
.speed-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.speed-stat-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-splits-wrap { margin-top: 4px; }
.detail-splits-wrap .detail-section-title { padding: 0 2px; margin: 0 0 4px; }
.detail-splits-wrap .evolution-chart { padding: 18px 0 4px; }

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.history-item:active {
  background: rgba(255, 255, 255, 0.09);
  transform: scale(0.99);
}
.history-item-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lilac);
  flex-shrink: 0;
}
.history-item-body { flex: 1; min-width: 0; }
.history-item-date { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.history-item-stats { font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.history-item-pace { font-size: 12px; color: var(--text-muted); text-align: right; }

.history-item-delete {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.history-item-delete:hover,
.history-item-delete:active {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
}

.history-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}
.history-empty p { margin: 4px 0; }
.history-empty-sub { font-size: 13px; color: var(--text-faint); }

/* ===================== toast ===================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: var(--glass-fill-strong);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  max-width: 86%;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===================== sheet de meta (stepper + presets) ===================== */

.goal-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 6px 0 2px;
}
.goal-step-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.32);
  color: var(--lilac);
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.goal-step-btn:active { background: rgba(139, 92, 246, 0.24); }
.goal-step-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 110px;
  justify-content: center;
}
#goal-step-number {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  color: var(--text-primary);
}
#goal-step-unit {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-muted);
}

.goal-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.goal-preset-chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}
.goal-preset-chip.active {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.5);
  color: var(--lilac);
}

/* ===================== barra de progresso da meta (corrida ativa) ===================== */

.goal-progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-top: -4px;
}
.goal-progress-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.goal-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--violet), var(--lilac));
  transition: width 0.4s ease;
}
.goal-progress-fill.reached {
  background: linear-gradient(90deg, var(--success), #6EE7B7);
}
.goal-progress-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ===================== base dos bottom sheets (camadas, meta, instalação) ===================== */

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.sheet-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet-panel {
  width: 100%;
  padding: 26px 22px calc(env(safe-area-inset-bottom, 0px) + 22px);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sheet-overlay.open .sheet-panel {
  transform: translateY(0);
}

.auth-title {
  font-family: var(--font-display);
  font-size: 19px;
  margin: 0;
}

.skip-btn {
  padding: 12px;
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: center;
}

.sheet-close {
  text-align: center;
  padding: 6px;
  color: var(--text-faint);
  font-size: 13px;
}

/* ===================== popup de anúncio (modal centralizado) ===================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-panel {
  width: min(340px, 92vw);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-overlay.open .modal-panel {
  transform: scale(1);
}

.ad-label {
  font-size: 10.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.ad-slot-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}

.ad-close-btn {
  padding: 10px 26px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

/* ===================== banner de navegação turno a turno ===================== */

.turn-banner {
  position: absolute;
  z-index: 3;
  left: 12px;
  right: 68px;
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.turn-banner-icon {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
}
.turn-banner-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.turn-banner-distance {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--lilac);
}
.turn-banner-instruction {
  font-size: 13px;
  font-weight: 600;
  color: var(--lilac);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===================== FABs flutuantes do mapa (camadas / tela ligada / seguir) ===================== */

.layers-fab {
  position: absolute;
  z-index: 2;
  right: 14px;
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
  color: #fff;
}

/* botões empilhados logo abaixo do de camadas — desligados por padrão
   (vidro escuro neutro); .fab-active indica que a função está ligada */
.wakelock-fab,
.follow-fab {
  position: absolute;
  z-index: 2;
  right: 14px;
  color: var(--text-primary);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}
.wakelock-fab {
  top: calc(env(safe-area-inset-top, 0px) + 126px);
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.follow-fab {
  top: calc(env(safe-area-inset-top, 0px) + 180px);
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.wakelock-fab.fab-active,
.follow-fab.fab-active {
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
  color: #fff;
}

.add-route-fab {
  position: absolute;
  z-index: 2;
  right: 14px;
  top: calc(env(safe-area-inset-top, 0px) + 126px);
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}
.add-route-fab.fab-active {
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
  color: #fff;
}

.draw-route-fab {
  position: absolute;
  z-index: 2;
  right: 14px;
  top: calc(env(safe-area-inset-top, 0px) + 180px);
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}
.draw-route-fab.fab-active {
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
  color: #fff;
}

/* ===================== painéis de planejamento de rota (sem overlay,
   pra não bloquear o toque no resto do mapa enquanto buscando/desenhando) ===================== */

#panel-route,
#panel-draw-route {
  align-items: stretch; /* .bottom-panel usa center por padrão (botão de iniciar) */
  background: #000;
  color: #fff;
}
#panel-route *,
#panel-draw-route * {
  color: #fff;
}
/* mantém o placeholder do campo de busca discreto — senão fica igual ao
   texto real digitado e a pessoa não percebe que é só uma dica */
#panel-route .route-search-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.route-panel-content {
  max-height: 62vh;
  overflow-y: auto;
}

.route-search-row {
  display: flex;
  gap: 8px;
}
.route-search-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-body);
}
.route-search-input::placeholder { color: var(--text-faint); }
.route-search-input:focus { outline: none; border-color: rgba(139, 92, 246, 0.5); }

.route-search-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.route-search-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}
.route-result-item {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  line-height: 1.4;
}
.route-result-item:active { background: rgba(139, 92, 246, 0.16); }

.route-search-empty {
  padding: 10px 14px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

.route-waypoints-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.route-waypoint-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
}
.route-waypoint-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.25);
  color: var(--lilac);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.route-waypoint-label {
  flex: 1;
  font-size: 12.5px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-waypoint-remove {
  color: var(--text-faint);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.route-info {
  display: flex;
  justify-content: center;
  gap: 22px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.12);
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--lilac);
}

.route-actions {
  display: flex;
  gap: 10px;
}
.route-clear-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-pill);
  padding: 13px;
}
.route-done-btn {
  flex: 1;
  margin-top: 0;
}

/* marcador numerado de ponto de rota no Leaflet */
.wr-route-marker-inner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  border: 2px solid #fff;
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.5);
}

.layers-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.layer-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}
.layer-option.active {
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(139, 92, 246, 0.4);
}
.layer-swatch {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid var(--glass-border);
}
.layer-swatch-padrao { background: linear-gradient(135deg, #cfd8dc, #90a4ae); }
.layer-swatch-escuro { background: linear-gradient(135deg, #1b1b2f, #0B0B14); }
.layer-swatch-satelite { background: linear-gradient(135deg, #3e5c3a, #1f2e1d); }
.layer-swatch-claro { background: linear-gradient(135deg, #f4f4f6, #dcdfe3); }
.layer-option-label {
  flex: 1;
  text-align: left;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-primary);
}
.layer-check {
  color: var(--violet);
  font-weight: 700;
  opacity: 0;
}
.layer-option.active .layer-check { opacity: 1; }

/* ===================== sheet de instalação PWA ===================== */

.install-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.install-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.install-header .auth-title { margin: 0; }

.install-lead {
  font-size: 14px;
  color: var(--text-muted);
  margin: -4px 0 4px;
  line-height: 1.5;
}

.install-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 8px;
}
.install-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.22);
  color: var(--lilac);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.install-step-icon {
  color: var(--lilac);
  flex-shrink: 0;
  margin-top: 1px;
}
.install-step-body { min-width: 0; }
.install-step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.install-step-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.install-note {
  font-size: 12px;
  color: var(--text-faint);
  margin: 4px 0 0;
  line-height: 1.5;
}

.install-native-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--purple), var(--violet-strong));
  color: #fff;
  font-weight: 600;
  font-size: 14.5px;
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.4);
}

/* marcador da rota (bolinha pulsante no leaflet) */
.wr-live-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.28);
}
