* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1f2933;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

#sidebar {
  width: 340px;
  flex: 0 0 340px;
  height: 100%;
  overflow-y: auto;
  padding: 16px 18px 40px;
  background: #f7f9fb;
  border-right: 1px solid #dde3ea;
}

#map {
  flex: 1 1 auto;
  height: 100%;
}

/* Multiply the hillshade onto the bright Positron base: white relief areas stay
   light, slopes darken — terrain shape without tinting the monochrome map. */
.hillshade-blend {
  mix-blend-mode: multiply;
}

h1 {
  font-size: 18px;
  margin: 0 0 6px;
}

h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #52606d;
  margin: 0 0 8px;
}

.hint {
  font-size: 12px;
  color: #616e7c;
  line-height: 1.45;
  margin: 0 0 16px;
}

section {
  border-top: 1px solid #e4e9ef;
  padding: 14px 0;
}

label {
  display: block;
  font-size: 12px;
  color: #3e4c59;
  margin-bottom: 10px;
}

label.check {
  display: flex;
  align-items: center;
  gap: 6px;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #cbd2d9;
  border-radius: 6px;
  background: #fff;
}

label.check input { width: auto; margin: 0; }

.row {
  display: flex;
  gap: 10px;
}
.row label { flex: 1; }

button {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 4px;
}

button.primary { background: #2563eb; color: #fff; }
button.primary:hover { background: #1d4ed8; }
button.danger { background: #fff; color: #b42318; border: 1px solid #f0c2bb; }
button.danger:hover { background: #fff5f3; }
button.warn-btn { background: #f59e0b; color: #1f2933; }
button.warn-btn:hover { background: #d97706; }

.filename {
  display: flex;
  align-items: center;
  gap: 4px;
}
.filename input { flex: 1; }
#file-ext { font-size: 13px; color: #616e7c; }

.area-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}
.area-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  background: #fff;
  border: 1px solid #e4e9ef;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
}
.area-list li.empty {
  color: #9aa5b1;
  font-style: italic;
  justify-content: center;
}
.area-list .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  flex: 0 0 22px;
}
.area-list .meta { flex: 1; color: #52606d; font-size: 12px; }
.area-list .meta strong { color: #1f2933; }
.area-list button.remove {
  width: auto;
  margin: 0;
  padding: 3px 8px;
  background: transparent;
  color: #b42318;
  font-size: 12px;
}

.summary {
  font-size: 12px;
  color: #52606d;
  margin: 10px 0 0;
  line-height: 1.5;
}

.legend ul { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.legend li { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.45);
}
.dot.a { background: #1f77b4; }
.dot.x { background: #d62728; }
.dot.i { background: #7c3aed; } /* imported */
.dot.u { background: #111827; } /* created */

/* Permanent labels on the map (X + custom) */
.wp-label {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0; /* Leaflet's default 6px padding pushed the text away from the dot */
  color: #7a1410;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 2px #fff;
}
.wp-label.imported { color: #6d28d9; }
.wp-label.created { color: #111827; }
.wp-label::before { display: none; }
/* Leaflet adds a 6px directional margin + a tip; drop them so the label sits
   right next to the dot (the marker offset provides the small gap). */
.wp-label.leaflet-tooltip-right { margin-left: 0; }
.wp-label.leaflet-tooltip-left { margin-right: 0; }
.wp-label.leaflet-tooltip-top { margin-top: 0; }
.wp-label.leaflet-tooltip-bottom { margin-top: 0; }

/* Generated markers (grid + X): white ring + thin dark outline so they read
   on any map background, matching the imported waypoint dots. */
.gen-marker {
  filter: drop-shadow(0 0 1px rgba(17, 24, 39, 0.9));
}

/* Custom (user) waypoint marker — colour set per group below */
.custom-wp-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #111827;
  cursor: grab;
}
.custom-wp-icon.imported { background: #7c3aed; }
.custom-wp-icon.created { background: #111827; }
/* Altitude disagrees with terrain — amber alert ring */
.custom-wp-icon.alt-warn {
  box-shadow: 0 0 0 2px #f59e0b, 0 0 0 4px rgba(245, 158, 11, 0.5);
}

/* "Show on map" — expanding ring pulse (box-shadow only, so it doesn't fight
   Leaflet's transform-based positioning) */
@keyframes wp-blink {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7); }
  70% { box-shadow: 0 0 0 20px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}
.custom-wp-icon.blink { animation: wp-blink 0.5s ease-out 5; }

.area-list .badge.locate { cursor: pointer; }

/* Custom waypoint list: Edit button + altitude warning flag */
.area-list button.edit {
  width: auto;
  margin: 0;
  padding: 3px 8px;
  background: transparent;
  color: #2563eb;
  font-size: 12px;
}
.alt-flag { color: #b45309; }

/* Edit modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 320px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.modal h2 {
  margin: 0 0 12px;
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
  color: #1f2933;
}
.modal label { font-size: 12px; color: #3e4c59; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}
.modal-actions button { width: auto; padding: 8px 16px; }
.modal-actions button:not(.primary) { background: #eef2f7; color: #3e4c59; }
.alt-note {
  font-size: 12px;
  color: #52606d;
  margin: 4px 0 0;
  min-height: 1.3em;
  line-height: 1.4;
}
.alt-note.warn { color: #b45309; }
.alt-note.ok { color: #2f855a; }
button.link {
  width: auto;
  margin: 0;
  padding: 0 2px;
  display: inline;
  background: none;
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
}

/* Floating "undo move" button over the map */
.undo-move {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 1000;
  width: auto;
  margin: 0;
  padding: 8px 16px;
  background: #1f2933;
  color: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  font-weight: 600;
}
.undo-move:hover { background: #111827; }

.busy { opacity: 0.6; pointer-events: none; }

/* Author / license footer at the bottom of the sidebar */
.about {
  border-top: 1px solid #e4e9ef;
  padding: 14px 0 0;
  font-size: 12px;
  color: #616e7c;
  line-height: 1.5;
}
.about p { margin: 0 0 4px; }
.about a { color: #2563eb; text-decoration: none; }
.about a:hover { text-decoration: underline; }
