*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --toolbar-bg: rgba(11, 43, 68, 0.94);
  --accent: #2980b9;
  --accent-active: #e74c3c;
  --text: #f0f8ff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #0b2b44;
  color: var(--text);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  background: var(--toolbar-bg);
  backdrop-filter: blur(8px);
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

#stage-select {
  flex: 1 1 140px;
  min-width: 0;
  min-height: 48px;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.95rem;
}

.btn {
  min-height: 48px;
  min-width: 48px;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
}

.btn-primary[aria-pressed="true"] {
  background: var(--accent-active);
}

.toggle-stages {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  min-height: 48px;
  padding: 0 0.25rem;
  white-space: nowrap;
}

.toggle-stages input {
  width: 18px;
  height: 18px;
}

#map {
  flex: 1;
  min-height: 0;
  width: 100%;
  z-index: 1;
}

.section-info {
  padding: 0.45rem 0.75rem 0.55rem;
  background: rgba(8, 32, 52, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 999;
}

.section-info-name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.section-info-stats {
  margin-top: 0.15rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(240, 248, 255, 0.82);
}

.status-banner {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(5.5rem + var(--safe-bottom));
  z-index: 1100;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(192, 57, 43, 0.95);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.35;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.status-banner.info {
  background: rgba(41, 128, 185, 0.95);
}

.status-banner.hidden {
  display: none;
}

.download-progress {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(5.5rem + var(--safe-bottom));
  z-index: 1100;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: rgba(11, 43, 68, 0.95);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.download-progress.hidden {
  display: none;
}

.download-progress-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

#download-progress-fill {
  height: 100%;
  width: 0%;
  background: #2ecc71;
  transition: width 0.2s ease;
}

#download-progress-text {
  font-size: 0.82rem;
  opacity: 0.9;
}

.fab {
  position: fixed;
  right: calc(0.85rem + var(--safe-right));
  bottom: calc(1rem + var(--safe-bottom));
  z-index: 1000;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #1a5276;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.fab:active {
  transform: scale(0.95);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Download progress bar */
.leaflet-control button {
  min-height: 36px;
}

@media (max-width: 420px) {
  .toolbar {
    gap: 0.35rem;
  }

  #btn-layer,
  #btn-corridor,
  .toggle-stages span {
    display: none;
  }
}
