:root {
  --anchorage-color: #2b6cb0;
  --pickup-color: #dd7a1f;
  --current-loc-color: #2f9e44;
  --danger-color: #c0392b;
}

* { box-sizing: border-box; }

.hidden { display: none; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #2d2d2d;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #e8e8e0;
}

/* Top bar */
#top-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

#app-title {
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#top-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
  flex-shrink: 0;
}

/* Search */
#search-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  pointer-events: auto;
}

#search-input {
  width: 100%;
  max-width: 260px;
  padding: 9px 14px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  color: #2d2d2d;
}

#search-input:focus {
  outline: 2px solid #1a5fb4;
  outline-offset: 1px;
}

#search-results {
  position: absolute;
  top: 100%;
  margin-top: 6px;
  width: 100%;
  max-width: 260px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  max-height: 240px;
  overflow-y: auto;
}

#search-results.hidden {
  display: none;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
  background: #f0f5fb;
}

.search-result-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-result-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-category {
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
}

.search-result-empty {
  padding: 10px 12px;
  font-size: 13px;
  color: #888;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  color: #2d2d2d;
  transition: background 0.15s ease;
}

.btn:hover { background: #f2f2f2; }

.icon-btn {
  border: none;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  font-size: 16px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.icon-btn:hover { background: #f2f2f2; }

#mode-toggle.active {
  background: #2d2d2d;
  color: #fff;
}

/* Edit toolbar */
#edit-toolbar {
  position: absolute;
  top: 64px;
  left: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

#edit-toolbar.hidden { display: none; }

.category-anchorage {
  border-left: 4px solid var(--anchorage-color);
}

.category-pickup {
  border-left: 4px solid var(--pickup-color);
}

#edit-hint {
  font-size: 12px;
  color: #666;
  max-width: 200px;
}

#edit-hint.active {
  color: #1a5fb4;
  font-weight: 600;
}

/* Toast */
.toast {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 1200;
  max-width: 90vw;
  text-align: center;
}

.toast.hidden { display: none; }

/* Overlays / modals */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  width: 320px;
  max-width: 90vw;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.modal h3 {
  margin: 0 0 14px 0;
  font-size: 16px;
}

.modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
  margin-top: 12px;
}

.modal input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}

.modal input[type="text"].input-invalid {
  border-color: var(--danger-color);
}

.modal input[type="range"] {
  width: 100%;
}

#marker-radius-value {
  font-size: 12px;
  color: #666;
  text-align: right;
}

.category-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.category-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #2d2d2d;
  margin: 0 !important;
  cursor: pointer;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.swatch-anchorage { background: var(--anchorage-color); }
.swatch-pickup { background: var(--pickup-color); }

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  gap: 8px;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn-primary {
  background: #1a5fb4;
  color: #fff;
}
.btn-primary:hover { background: #154e94; }

.btn-secondary {
  background: #eee;
  color: #2d2d2d;
}
.btn-secondary:hover { background: #ddd; }

.btn-danger {
  background: var(--danger-color);
  color: #fff;
}
.btn-danger:hover { background: #a3301f; }

/* Leaflet tooltip label styling */
.marker-label {
  background: rgba(255, 255, 255, 0.85);
  border: none;
  box-shadow: none;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  color: #2d2d2d;
}
.marker-label::before { display: none; }

.resize-handle-icon {
  background: transparent;
  border: none;
}

.resize-handle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #1a5fb4;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  cursor: ew-resize;
}

.move-handle-icon {
  background: transparent;
  border: none;
}

.move-handle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #1a5fb4;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  cursor: move;
}

.current-location-icon {
  background: transparent;
  border: none;
}

.current-location-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--current-loc-color);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--current-loc-color), 0 1px 4px rgba(0,0,0,0.4);
}

@media (max-width: 480px) {
  #app-title { font-size: 12px; padding: 6px 10px; }
  .btn { padding: 8px 10px; font-size: 13px; }
  #search-input { padding: 8px 10px; font-size: 13px; }
}
