.map-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: visible;
  background: var(--surface-elevated);
}

.map-controls {
  position: relative;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.map-search {
  width: min(340px, 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}

.geofence-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.geofence-helper {
  color: var(--muted);
  font-size: 0.76rem;
}

.geofence-colors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.geofence-colors label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--surface);
}

.geofence-color-option--high {
  border-color: #39a860;
  color: #39a860;
}

.geofence-color-option--low {
  border-color: #d6992e;
  color: #d6992e;
}

.geofence-color-option--stress {
  border-color: #d14343;
  color: #d14343;
}

.geofence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: var(--space-3);
  border-top: 1px solid var(--border);
}

.geofence-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid currentColor;
}

.geofence-chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.map-search-results {
  position: absolute;
  z-index: 300;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  width: min(340px, calc(100% - 32px));
}

.map-search-results button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
}

.map-search-results button:hover { background: var(--primary-soft); }

.map-mode-controls {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.map-mode-btn {
  border: 0;
  background: var(--surface);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.map-mode-btn + .map-mode-btn {
  border-left: 1px solid var(--border);
}

.map-mode-btn:hover {
  color: var(--text);
  background: var(--primary-soft);
}

.map-mode-btn.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.map-opacity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.map-opacity input[type="range"] {
  width: 120px;
}

.map-opacity strong {
  min-width: 36px;
  text-align: right;
  color: var(--text);
  font-size: 0.78rem;
}

.map-canvas {
  height: 360px;
  position: relative;
  z-index: 1;
}


.geofence-modal[hidden] {
  display: none !important;
}

.geofence-modal {
  position: absolute;
  inset: 0;
  z-index: 650;
  display: grid;
  place-items: center;
  background: rgba(5, 11, 21, 0.48);
  padding: var(--space-4);
}

.geofence-modal__card {
  width: min(420px, 100%);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  display: grid;
  gap: var(--space-3);
}

.geofence-modal__card h3,
.geofence-modal__card p {
  margin: 0;
}

.geofence-modal__label {
  font-size: 0.8rem;
  color: var(--muted);
}

.geofence-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.legend {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
}

.legend span::before {
  content: "";
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 6px;
}

.legend .high::before { background: #39a860; }
.legend .watch::before { background: #d6992e; }
.legend .losing::before { background: #d14343; }
