* { box-sizing: border-box; }

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

body { display: flex; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: #f7f8fa;
  border-right: 1px solid #dde1e7;
  padding: 14px 16px 24px;
  overflow-y: auto;
}

#sidebar h1 { font-size: 19px; margin: 0 0 12px; }
#sidebar h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5a6472;
  margin: 0 0 8px;
}
#sidebar section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e8ed;
}

.hint { color: #5a6472; font-size: 12.5px; line-height: 1.45; margin: 0 0 8px; }

textarea, input[type="text"], select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #c9cfd8;
  border-radius: 6px;
  font: inherit;
  background: #fff;
  margin-bottom: 8px;
}
textarea { resize: vertical; }

.row { display: flex; gap: 6px; align-items: center; }
.row label { flex: 1; font-size: 12px; color: #5a6472; }
.row select { margin-bottom: 0; margin-top: 3px; }
.row input, .row button { margin-bottom: 0; }
#proj-list { flex: 1; }

button {
  padding: 7px 12px;
  border: 1px solid #c9cfd8;
  border-radius: 6px;
  background: #fff;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: #eef1f5; }
button.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
button.primary:hover { background: #1d4fd7; }
button.big { width: 100%; padding: 10px; font-size: 15px; margin-top: 10px; }
button.danger-outline { color: #c0392b; border-color: #e4b6b0; }
button.danger-outline:hover { background: #fbeeec; }

#loc-list { list-style: none; margin: 10px 0 0; padding: 0; }
#loc-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px dashed #e5e8ed;
  font-size: 13px;
}
#loc-list li .swatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex: 0 0 12px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}
#loc-list li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#loc-list li .remove { border: none; background: none; color: #9aa3af; padding: 2px 4px; }
#loc-list li .remove:hover { color: #c0392b; background: none; }
#loc-list li.error .name { color: #c0392b; }

.check { display: block; margin: 6px 0; cursor: pointer; }

#status {
  font-size: 12.5px;
  color: #5a6472;
  min-height: 18px;
  white-space: pre-wrap;
}
#status.error { color: #c0392b; }

/* ---------- Map ---------- */
#map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }
#map.annotate-mode .maplibregl-canvas-container { cursor: crosshair; }

#mode-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  display: flex;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.25);
  overflow: hidden;
}
#mode-toggle button {
  border: none;
  border-radius: 0;
  padding: 8px 14px;
  background: #fff;
}
#mode-toggle button.active { background: #2563eb; color: #fff; }

#export-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(255,255,255,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 16px;
  color: #1f2733;
}
#export-overlay[hidden] { display: none; }
.spinner {
  width: 38px; height: 38px;
  border: 4px solid #c9cfd8;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Location markers ---------- */
.loc-marker { width: 0; height: 0; }
.loc-marker .dot {
  position: absolute;
  width: 16px; height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.loc-marker .tag {
  position: absolute;
  top: 12px;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.92);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ---------- Annotations ---------- */
.ann-root { width: 0; height: 0; pointer-events: none; }
.ann-root svg.ann-leader {
  position: absolute;
  overflow: visible;
  width: 1px; height: 1px;
  left: 0; top: 0;
}
.ann-dot {
  position: absolute;
  width: 14px; height: 14px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
  cursor: grab;
  pointer-events: auto;
}
.ann-dot:active { cursor: grabbing; }

.ann-label {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 50px;
  min-height: 26px;
  padding: 5px 9px;
  background: rgba(255,255,255,0.95);
  border: 2px solid #e74c3c;
  border-radius: 7px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.3);
  cursor: move;
  pointer-events: auto;
  resize: both;
  overflow: hidden;
}
.ann-label.no-bg {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 5px #fff;
}
.ann-root.selected .ann-label { outline: 2px dashed #2563eb; outline-offset: 3px; }
.ann-text {
  outline: none;
  line-height: 1.35;
  word-wrap: break-word;
  cursor: inherit;
}
.ann-label.editing { cursor: text; }
.ann-label.editing .ann-text { cursor: text; }

.ann-toolbar {
  position: absolute;
  display: none;
  transform: translate(-50%, -100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  padding: 6px 8px;
  gap: 5px;
  align-items: center;
  pointer-events: auto;
  white-space: nowrap;
  z-index: 10;
}
.ann-root.selected .ann-toolbar { display: flex; }
.ann-toolbar .swatch {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
  cursor: pointer;
  padding: 0;
}
.ann-toolbar input[type="color"] {
  width: 24px; height: 24px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}
.ann-toolbar button {
  padding: 3px 7px;
  font-size: 12px;
  border-radius: 5px;
}
.ann-toolbar .sep { width: 1px; height: 20px; background: #dde1e7; }
.ann-toolbar .del { color: #c0392b; }
.ann-toolbar select {
  width: auto;
  padding: 3px 4px;
  margin: 0;
  font-size: 12px;
  border-radius: 5px;
}
.ann-toolbar .bold-toggle.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
